2

これが私のコードです

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title></title>
</head>
<body>
<div id="fb-root">
</div>
<script>
       window.fbAsyncInit = function () {
        FB.init({
            appId: 'XXXXXX', // App ID
            channelUrl: '//localhost:63651/channel.htm', // Channel File
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true,  // parse XFBML
            oauth: true
        });

        // Additional initialization code here
    };

    // 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/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    } (document));
</script>
<input type="button" value="login" id="login" onclick="return login();" />
<script>

    function login() {

        FB.login(function (response) {
            if (response.authResponse) {
                console.log('Welcome!  Fetching your information.... ');
                FB.api('/me', function (response) {
                    alert(response);
                    console.log('Good to see you, ' + response.name + '.');
                });
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        }, { scope: 'email,user_work_history,publish_stream' });



    }
</script>
</body>
</html>

だから私の問題は、FacebookのダイアログがIE9の許可に固執していることです。以下Facebookエラー
をクロムで参照してくださいが、このエラーが発生します

Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/dialog/permissions.request from frame with URL http://localhost:63651/plans/. Domains, protocols and ports must match.

私はfbのドキュメントで説明されているのと同じコードを使用しました。

何か助けはありますか?
必要に応じて詳細を提供できます。私はすべての選択肢がありません。
ありがとう

4

1 に答える 1

1

channelURL ファイルをインターネット (localhost URL なし) とデフォルトの http ポート (80) に配置してみてください。問題は、接続用の別のポートを認識していないか、インターネット (localhost ではなく) に公開したいことです。

    FB.init({
        appId: 'XXXXXX', // App ID
        channelUrl: '//your-website.com/channel.htm', // Channel File
        status: true, // check login status
        cookie: true, // enable cookies to allow the server to access the session
        xfbml: true,  // parse XFBML
        oauth: true
    });
于 2012-05-31T08:44:59.597 に答える