Noam
Noam

Reputation: 3391

Specifying API version in Facebook PHP SDK

I'm trying to move to Facebook's newer API versions (v2 and above). I'm still not sure if I'm going to also update to the newest SDK (v4.4) or keep my old (v2). But I don't see any way to specify the API version in any of them. All I see in the docs are how to do that in manual calls (/v2.0/me) or in different SDKs. This is the API docs I found about versioning calls: https://developers.facebook.com/docs/apps/versions

How do I specify the API versioning through the SDK?

Upvotes: 0

Views: 1082

Answers (1)

daviddoran
daviddoran

Reputation: 528

Let's take the following example from the PHP SDK v4 README:

$me = (new FacebookRequest(
  $session,
  'GET',
  '/me'
))->execute()->getGraphObject(GraphUser::className());

echo $me->getName();

We can make the same request with an explicit version (e.g. v2.3):

$me = (new FacebookRequest(
  $session,
  'GET',
  '/me',
  null,
  'v2.3'
))->execute()->getGraphObject(GraphUser::className());

echo $me->getName();

The 3.x SDK doesn't have the concept of versioning so you'd need to add v2.x to the front of your request paths yourself.

Upvotes: 1

Related Questions