Apr 5, 2015

Added v2.3 support to Facebook::OpenGraph

Last weekend I added Graph API v2.3 support to Facebook::OpenGraph, and released it to CPAN. Basically this module does not require a lot of code change to support different API versions because it focuses on minimal implementation with maximum convenience. When I designed it, I did not want to require developers to cover both Graph API and this module's specification; Client modules should be as thin as possible so developers do not have to be conscious of its existence.
This time, however, Graph API v2.3 has major change on /oauth/access_token response. It used to return URL encoded query string, but is going to return JSON object from its latest version. So I added several new methods and some code change as below:
  • Now Facebook::OpenGraph::Response has methods for Graph API version comparison
  • Facebook::OpenGraph checks API version, and if it is higher than v2.3, it parses the response body as JSON object
These version comparison methods are handy. $response->api_version returns API Version that is returned from Graph API, which I think is safer than using the version given by developers. The designated version and actual experiencing version may differ sometimes as described on document.
we now return an HTTP response header called 'facebook-api-version' which indicates which API version your app is actually experiencing - this may be different to the API version you specify in your request due to upgrades.
I am not creating brand new Facebook App lately, so there might be some edge-cases that I am missing. I will be happy to have your feedback on github.