Posts
-
The Twitter API has a few quirks
At Octoblu, we pride ourselves in supporting as much of our built-in API’s as possible. However, we had some serious issues getting Twitter’s API to function the way we’d expect.
POST Content-type encoding
Most modern REST API’s will take a look at your request’s
Read moreContent-type
header. If theContent-type
is declared asapplication/json
, then the server expects your post body to be JSON. If theContent-type
isx-www-form-urlencoded
, then the body should be form and url encoded. Twitter, however, will only accept x-www-form-urlencoded post bodies. YourContent-type
will be ignored, and you will get a very unhelpful HTTP 403 status code back with an empty body. Unfortunately, this means that you will have to form and url encode your POST and PUT requests, which leads us into the next quirk. -
Forcing Angular directive rendering
At Octoblu, we recently ran into an interesting problem with Angular.JS.
We have an html panel that contains an Angular Directive. The code looks a little something like this:
The issue that we ran in to is this: we swap out the model represented by
Read moremyModel
all the time. On initialization, the directive’s controller sets up some listeners and fetches some resources from the backend (provided they aren’t already cached), and does some other stuff. However, the directive is not re-rendered (and thus controller initialization is not run) each time the model reference changes.
subscribe via RSS