gpt4 book ai didi

javascript - 如何使用 facebook JS SDK 捕获页面加载时喜欢的页面?

转载 作者:行者123 更新时间:2023-12-03 05:54:34 26 4
gpt4 key购买 nike

嗨,我想知道页面加载时是否通过 facebook like 按钮获得点赞。我正在尝试使用 user_likes 权限执行 fb graph api 工作正常。我无法从 Facebook 获得此许可,他们说我们的应用程序当前功能不需要此许可。如果没有用户喜欢的权限,我可以在页面加载时获得喜欢或不喜欢吗?这是我的具有 user_likes 权限的代码示例。

window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxx',
status : true,
xfbml : true
});
FB.Event.subscribe('edge.create',
function(response) {
window.location.href = 'xyz.com';
}
);

FB.Event.subscribe('edge.remove',
function(response) {
<!-- alert('You UNliked the URL: ' + response); -->
window.location.href = 'xxx.com';
}
);
FB.getLoginStatus(function(response){
FB.api(
'/me/likes/xxxxx',
'GET',
{},
function(response) {
if(response.data[0])
{
alert(response);
window.location.href = 'xyz.com';
}
}
);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&version=v2.7&appId=xxxxxxx";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

最佳答案

不可以,如果没有 user_likes 权限,您就无法获得“赞”状态。您还应该考虑在执行 API 调用之前检查登录状态:

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
//user is authorized
FB.api(...);
} else {
//user is not authorized
}
});

来源:http://www.devils-heaven.com/facebook-javascript-sdk-login/

关于javascript - 如何使用 facebook JS SDK 捕获页面加载时喜欢的页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39994511/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com