Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choose Graph API or old REST API for Facebook application

Tags:

facebook

I should have asked this in Facebook developer forum instead, but somehow I can't register to the forum and the Facebook connect feature is not working at the time I'm writing this.

Anyway, I am still confused whether to use Graph API or the old REST API for my Facebook app. Generally, this is what I want to achieve in my app:

  1. Get profile picture and name of the user.
  2. Get profile picture and name of the user's friends who are also using my app.
  3. Post into the user's stream.
  4. Allow users to invite their friends to use the application.

Can someone provide me an insight, which one is better for my application?

like image 397
Andree Avatar asked Apr 22 '10 09:04

Andree


2 Answers

As Renesis said, the Graph API covers exactly what you need for the first three steps.

For the fourth point, I've been looking at the API extensively for my own apps and have found out how to do it via FBML with the following code:

<fb:serverFbml>
<script type="text/fbml">
<fb:fbml>
    <fb:request-form
        method='POST'
        type='join my Smiley group'
        content='Would you like to join my Smiley group? 
            <fb:req-choice url="http://apps.facebook.com/smiley/yes.php" 
                label="Yes" />'
            <fb:req-choice url="http://apps.facebook.com/smiley/no.php" 
                label="No" />'
        <fb:multi-friend-selector 
            actiontext="Invite your friends to join your Smiley group.">
    </fb:request-form>
</fb:fbml>
</script>
</fb:serverFbml>

http://developers.facebook.com/docs/guides/canvas/#requests

It seems as though Scott's incorrect when he says Graph incorporates everything the old REST API has:

"We are currently in the process upgrading our core server API from the old REST API to the more modern Graph API. However, most of the methods required for canvas applications to integrate with Facebook have not yet been upgraded to the new API. For the time being, we recommend you continue using the old REST API in canvas apps instead of the new APIs for the sake of completeness."

(I can only post one hyperlink, so it's the same one as the #requests hyperlink but in the 'Making API calls' section)

Not sure if this is the case with other methods of integration such as web or desktop apps, but so far it seems as though the Graph API has a little bit of catching up to do!

Edit:

To list the profile pictures of a user's friend, use the following:

Assuming you've already got the current user's ID

https://graph.facebook.com/**USER-ID**/friends?fields=picture,name&access_token=**ACCESS-TOKEN**

This will provide a JSON object with a list of the current user's friends containing the UID, name and a link to the small version of the profile picture.

I haven't found a way to retrieve the large picture version in a search yet so with that method, if you wanted the large version, you'd have to iterate through each user and use this:

https://graph.facebook.com/**USER-ID**/picture?type=large
like image 196
tonyhb Avatar answered Oct 07 '22 01:10

tonyhb


  1. Get profile picture and name of the user.
    • http://graph.facebook.com/[uid] for the name and http://graph.facebook.com/[uid]/picture is an always up-to-date link to the current picture. Also, if you have an access_token, you can query http://graph.facebook.com/me for data on the current user, whoever that is.
  2. Get profile picture and name of the user's friends who are also using my app.
    • Not sure about how to get the specific friends only, maybe using FQL. However, note that you can get specific fields in the friends list (defaults to just name and id) by adding a fields parameter: .../friends?fields=id,name,picture
  3. Post into the user's stream.
    • Perform an HTTP POST to http://graph.facebook.com/[uid]/feed with a body parameter. (see http://developers.facebook.com/docs/api#publishing)
  4. Allow users to invite their friends to use the application.
    • Sorry, not sure on this one...
like image 24
Nicole Avatar answered Oct 07 '22 00:10

Nicole