Kiwi
Kiwi

Reputation: 2773

facebook API v2 get cover photo

I'm trying to get a user his facebook cover, but I can't seem to figure out what te correct url is for that.

I tried using the graph.facebook.com, but that is for a different id (not the scoped one?)

I can get the profile picture via https://graph.facebook.com/'.$loginInfo->id.'/picture?type=large but I can't seem to find how to fetch the cover photo.

When i go to https://graph.facebook.com/username i get an other id, but both can be used to get the profile picture. and both link to the users his profile page

I'm using a bundle to do the facebook login, and like that I get my id. so how would I get the cover photo?

greetings kiwi

Upvotes: 0

Views: 1426

Answers (3)

Awi
Awi

Reputation: 295

Once you got the userId, you can get the image via JavaScript (or its equivalent in php api) with this call:

function getProfileCover(userId) {
  FB.api(
    "/" + userId + "/picture",
    function(response) {
      if (response && !response.error) {
        facebookMeObject.cover = response.data.url;
      }
    }
  );
}

Upvotes: 0

Wenger
Wenger

Reputation: 989

You have to get the source via an api call.

Graph path: me?fields=cover

That JSON result will have an other embedded JSON object called "cover" (redundant, I know), and in that JSON object is a field called "source".

Upvotes: 0

Tobi
Tobi

Reputation: 31479

How about using

/me?fields=id,cover

as a request? me is always referencing the actual user which is contained in the Access Token.

Upvotes: 1

Related Questions