我想更改頁面網址的位置,我強烈希望在單獨的窗口中打開權限請求對話框。如何在JavaScript中自定義Facebook oauth對話框?
這是JavaScript的即時通訊使用:
<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>
,在一個單獨的窗口出現在所有的瀏覽器沒有顯示出來,再用IE對話框...
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',
));
}
你能分享整個代碼嗎?上面的代碼片段不會提示用戶安裝你的應用程序! – ifaour
你還在找什麼? –
什麼是觸發auth對話框打開?如果你看看[example.php](https://github.com/facebook/php-sdk/blob/master/examples/example.php)和文檔,你可以看到有可能構建登錄網址並將用戶重定向到它。 – ifaour