Ok, one of my beefs with Facebook’s new F8 platform is it’s horrible documentation.
It takes me maybe an hour to figure out how to do something as simple figure out how to use the API.
In case anyone is looking for that information here’s the scoop:
Every API call is made using this structure - $facebook->api_client->
Each of the calls can be found here.
Here’s what they don’t tell you, each of these API methods have to be translated before they can be used.
Example 0.1 - Creating a call
If you would like to know if 2 users are friends, you use the friends.areFriends call, but the proper code is not
$facebook->api_client->friends.areFriends(). Instead, it is $facebook->api_client->friends_areFriends();
Greaaaaaat, now we just have to figure out how to use it.
Example 1 - Are 2 users friends?
From the API documentation, we can see that friends.areFriends takes in 2 arrays, uids1, and uids2 to compare. That means that we need to pass 2 arrays. Our code comes out to look something like this:
$friend_case = $facebook->api_client->friends_areFriends(array($user1), array($user2));
If you look at the response,
<friend_info>
<uid1>1240077</uid1>
<uid2>1240078</uid2>
<are_friends xsi:nil="true"/>
</friend_info>
You can see that the ‘are_friends’ is what holds the information we want, so to access it, we call
$are_friends = $friend_case[0];
$are_friends[’are_friends’].
There. Simple, isn’t it? But not something that can always be apparent to everyone. I really wish that Facebook would just put a bit more manpower on their own documentation, so that their users wouldn’t have to.
Share This