Facebook Javascript SDK - Request Profile Image

I am trying to request a profile image through the Javascript SDK.

I do not want a link to the api chart , I want to get the src_big link.

I have the following code:

 FB.api("/me", {fields: "id,name,picture"}, function(response) { alert( response.picture ); FB.api( { method: 'fql.query', query: 'SELECT pid, src_big, src_big_height, src_big_width FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner="' + response.id + '" AND name = "Profile Pictures")' }, function(data1) { alert('BIG ' + data1.pic_big ); } ); }); 

He should give me src_big , but that is not the case. Has anyone been successful with this?

+4
source share
3 answers

The problem was not during the request; the problem was accessing the object.

It must be accessed in a strange way.

 FB.api("/me", {fields: "id,name,picture"}, function(response) { FB.api( { method: 'fql.query', query: 'SELECT pid, src_big, src_big_height, src_big_width FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner="' + response.id + '" AND name = "Profile Pictures")' }, function(data1) { alert( data1[0].src_big ); } ); }); 

thanks

+4
source

I tried this, could not get it to work, but it happened:

You can get specific pic profile sizes.

 FB.api("/me/picture?width=180&height=180", function(response) { console.log(response.data.url); }); 

See the Facebook documentation for what different image sizes you can get .

And my demo with the login at: Get an image on Facebook using the Javascript SDK

+3
source

You tried to get the profile image from the fql user table.

Request will be

 "select uid, pic, pic_small, pic_big, pic_square from user where uid=me()" //replace this me() with the id of the user 

This will return the entire link for profile images.

What are you trying to get from user albums ...

0
source

Source: https://habr.com/ru/post/1385808/


All Articles