[英]How do I get the Facebook access token when using the JavaScript API?
I need to link to the cover picture of an album on Facebook. 我需要链接到Facebook上专辑的封面图片。 This method works: 此方法有效:
img.src = "https://graph.facebook.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? 但是使用FB._session.access_token看起来并不正确......有更好的方法吗? 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. 我不能让FB.api()为此工作,可能是因为响应是重定向到实际图像数据的URL。
You could have a look here : How to get access token from FB.login method in javascript SDK 你可以看一下: 如何从javascript SDK中的FB.login方法获取访问令牌
FB.login(function (response) {
if (response.session) {
var access_token = response.session.access_token;
alert(access_token);
} else {
alert('User is logged out');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.