On 2014-04-30 Facebook announced API versioning to improve its stability. Each version is guaranteed to work 2 years so we do not have to be afraid of 90 day breaking change policy anymore. The version we were using prior to this introduction is called version 1.0 while the new version introduced along with API versioning policy is called version 2.0.
Versioned Request
Making versioned request is pretty easy. Just like other major platform APIs, you prepend version number to the end point like below:
/v2.0/me/friends
Unversioned request is also supported. Just don't prepend version number and it's considered "unversioned." The document says "An unversioned call will default to the oldest available version of the API," but here is one
tricky part:
For apps that existed before April 30th 2014, making an API call without specifying a version number ('unversioned') is equivalent to making a call to the v1.0 of the API.
For apps created on or after April 30th 2014, making an API call without a specifing a version number is equivalent to making a call to v2.0 of the API.
So when you are making unversioned request, just be careful when the request app was created.
Facebook::OpenGraph 1.21
I implemented versioning support to Facebook::OpenGraph and launched it as Ver. 1.21. This change is backward compatible. If you update module and don't make any change to your code it makes unversioned request, which is exactly the same as previous version of this module.
API Versioning
With this version, you can specify default version on initialization as follows:
my $fb = Facebook::OpenGraph->new(+{
app_id => 12345,
secret => 'qwerty',
version => 'v2.0',
});
If you don't specify any version, version is left undef and each request becomes unversioned request.
You can still set version on each request by specifying versioned path such as /v1.0/me/friends. This will override the version configuration given on initialization.
my $fb = Facebook::OpenGraph->new(+{version => 'v2.0'});
$fb->get('/zuck'); # Use version 2.0 by accessing /v2.0/zuck
$fb->get('/v1.0/zuck'); # Ignore the default version and use version 1.0
my $fb = Facebook::OpenGraph->new();
$fb->get('/zuck'); # Unversioned API access since version is not specified
# on initialisation or each reqeust.
Dialog Versioning
Facebook Platform also supports
dialog versioning. If you specify version -- let's say v2.0 -- on initialization, $fb->auth_uri() will return versioned Login dialog URL like https://www.facebook.com/v2.0/dialog/oauth.
If you have any enhancement idea, bug fix or question. Feel free to add an
issue.