0
votes

I'm working on a web application which is mostly based of Facebook Graph API. I hold some user's data - actually , the possible public data available - such as profile picture, name and id. I wondered how I'll be able to get a direct link to a user cover picture of a user only by using his id? and I already got the User ID.

This is the code that I used to get the profile picture & it worked-

 <img src="https://graph.facebook.com/{{user.id}}/picture?type=large" style="float:left;"/>

Now I want to get cover picture.

Thanks in advance.

1
do you have value for user.id ? - Kalhan.Toress
use ng-src instead of src. if that does not work store the full url in a scope variable and pass that to ng-src. - chandings
suggession by @chandings will work. :) - Kalhan.Toress
@chandings How can I do it? Isnt there a direct link - Mayura Wijewickrama
$scope.profilePicURL = "graph.facebook.com/"+user.id+"/picture?type=large"; <img ng-src="{{profilePicURL }}" style="float:left;"/> This should work. - chandings

1 Answers

1
votes

To get the cover picture of a user, make this call-

\GET http://graph.facebook.com/{user-id}?fields=cover

You'll get the image url in source key of the JSON response:

{
  cover: {
    id: "111222333",
    offset_y: 55,
    source: "https://scontent-a.xx.fbcdn.net/.....jpg"  // that's the cover photo url
  },
  id: "111222"
}