[英]How can I customize facebook oauth dialog in javascript?
I would like to change the location of the page url and I would strongly prefer to have the permissions request dialog open in a separate window. 我想更改页面URL的位置,并且我强烈希望在单独的窗口中打开权限请求对话框。
This is the JavaScript im using: 这是JavaScript im使用:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXXXXXXXXXXX',
status : true,
cookie : true,
xfbml : true
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
The dialog that comes up in a separate window doesn't show up in all browsers, freaking IE... 单独的窗口中显示的对话框并非在所有浏览器中都显示,这使IE浏览器...
PHP: PHP:
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'XXXXXXXXXXXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// n or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl( array(
'scope' => 'publish_stream,user_birthday,email,offline_access',
'next' => 'LINK HERE',
));
}
Instead of attempting to subvert Facebook's JavaScript SDK, simply use the standard OAuth authentication, which allows you to redirect the user to an authentication or permissions dialog without a JavaScript popup. 无需尝试颠覆Facebook的JavaScript SDK,只需使用标准的OAuth身份验证,该身份验证可让您将用户重定向到身份验证或权限对话框,而不会弹出JavaScript。
See the Server-Side Flow section of the Authentication documentation and the Direct URL Example in the OAuth dialog's documentation . 请参阅身份验证文档的服务器端流程部分和OAuth对话框文档中的直接URL示例 。 Note that the example URL in the latter documentation looks extremely similar to your second screenshot.
请注意,后一文档中的示例URL看起来与第二个屏幕截图极为相似。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.