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 Content-type header. If the Content-type is declared as application/json, then the server expects your post body to be JSON. If the Content-type is x-www-form-urlencoded, then the body should be form and url encoded. Twitter, however, will only accept x-www-form-urlencoded post bodies. Your Content-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.

    Read more
  • 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:

    <div class="panel-body">
      <custom-directive ng-model="myModel">
    </div>

    The issue that we ran in to is this: we swap out the model represented by myModel 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.

    Read more

subscribe via RSS