在 iOS Chrome 上共享 URL 时出现错误后,我修改了代码,以便它打开一个窗口并通过 OAuth 检查登录状态。
https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.1
$singleSocialLinks.on('click', 'a.fb', function() {
if( navigator.userAgent.match('CriOS') ) {
window.open('https://www.facebook.com/dialog/oauth?client_id=xxx&redirect_uri='+ document.location.href +'&scope=email,publish_actions', '', null);
} else {
// FB.login(null, {scope: 'email,public_profile'});
FB.ui({
method: 'share',
href: document.location.href
},
function(response){
console.log(response);
});
}
});
目前,它会返回到与预期相同的 URL,其中 url 中包含“code”response_type。我需要使用这个才能分享吗?确认用户身份验证后,我可以使用回调或其他 Facebook 参数吗?另外,SDK 什么时候可以在 IOS chrome 中使用(如果有的话)?
我也尝试了不同的网址、范围和大多数其他参数,但我似乎在此时遗漏了一些明显的语法。
请您参考如下方法:
嗨,当我们使用fb.ui在我们的项目中开发fb共享时,我也遇到了类似的问题。所以我厌倦了以下解决方法,它解决了我通过 Facebook 身份验证共享文章的问题。我面临的唯一问题是因为我使用了 window.open 我的所有 Facebook 身份验证、共享对话框和文章重定向都是在新选项卡中完成的。
下面是我的代码:
jsq("element class").on('click', function(e) {
e.preventDefault();
if(navigator.userAgent.match('CriOS')){
window.open('https://www.facebook.com/dialog/share?app_id='+fbAppid + '&display=popup&redirect_uri='+ location.href +'&href='+location.href+'&scope=email,publish_actions', '', null);
}else{
FB.ui({
method: 'share',
href: location.href
}, function(response){
if(typeof response !='undefined'){
# method to be called.
}
});
}
});
if(navigator.userAgent.match('CriOS')){
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
#method to be called.
}
});
}