开发者

How do I get the Facebook access token when using the JavaScript API?

开发者 https://www.devze.com 2023-02-05 10:31 出处:网络
I need to link to the cover picture of an album on Facebook. This method works: img.src = \"https://graph.facebo开发者_StackOverflow中文版ok.com/<album_id>/picture?access_token=\' +

I need to link to the cover picture of an album on Facebook. This method works:

 img.src = "https://graph.facebo开发者_StackOverflow中文版ok.com/<album_id>/picture?access_token=' + 
           FB._session.access_token;

But using FB._session.access_token doesn't look right...is there a better way? A pointer to the relevant docs would be nice, I couldn't find it myself.

I can't make FB.api() work for this, probably because the response is a redirect to the URL of the actual image data.


You could have a look here : How to get access token from FB.login method in javascript SDK

FB.login(function (response) {
    if (response.session) {
        var access_token = response.session.access_token;
        alert(access_token);
    } else {
        alert('User is logged out');
    }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消