sách gpt4 ai đã đi

facebook - 使用 Facebook 登录时点赞 Facebook 页面

In lại 作者:行者123 更新时间:2023-12-02 21:41:26 27 4
mua khóa gpt4 Nike

我在我的网页上使用 Facebook 登录。首次登录时,Facebook 登录应用程序会请求获取用户数据的权限。

有什么方法可以改善这个问题,以请求喜欢我的 Facebook 页面的许可?用户点击后,他也会喜欢我的 Facebook 页面。

编辑:我的目标是强制人们喜欢我的 Facebook 页面,如果他们想用 Facebook 帐户登录我的页面(不是常规注册)。当然,我会请求许可不违反使用条款。但如果当他们点击登录并授予权限时他们也会喜欢我的 Facebook 页面,那就太好了。因此 Facebook 登录和点赞不会分开。

1 Câu trả lời

当然,您刚刚将范围 user_likes 添加到 Facebook 登录按钮。

您可以阅读有关 facebook 登录按钮和范围属性的更多信息 đây

现在您可以访问用户喜欢的内容了,您可以检查用户是否喜欢您的页面,如果喜欢,很好,只需将用户重定向到您的网站,如果不喜欢,只需提示他喜欢您的页面,然后才能访问该页面您网站的其余部分。

这是一些使用 Facebook Javascript SDK 的代码


window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});

FB.Event.subscribe('auth.statusChange', handleStatusChange);
FB.Event.subscribe('edge.create', like);
};

// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/pt_PT/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));

然后在页面底部,放置这段javascript代码


//this function is fired whenever the user presses the like button
function like(response) {
if(response="https://www.facebook.com/YOUR_PAGE_USERNAME")
//do something when the user likes your page, like redirect him, or something like that
}
//this function is fired everytime the page is loaded
function handleStatusChange(response) {
if (response.authResponse) {
updateUserInfo(response);
}
}
//this function is called by the function handleStatusChange and it checks everytime the page is loaded if the user already likes your page
function updateUserInfo(response) {
token = response.authResponse.accessToken;
FB.api('/me/likes/YOUR_PAGE_ID', function(response) {
if(response.data.length){
//the user already likes your page
}
else{
//the user doesn'y like your page, or the user hasn't granted permission for you to access his likes. show him the like button
}
}, {access_token: token});

}

关于facebook - 使用 Facebook 登录时点赞 Facebook 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17817073/

27 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com