2

Facebook UI コールバックを実行できません。FB 開発サイトの例を使用しました。

https://developers.facebook.com/docs/reference/dialogs/feed/

FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});

function postToFeed() {

    // calling the API ...
    var obj = {
      method: 'feed',
      redirect_uri: 'YOUR URL HERE',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: 'Facebook Dialogs',
      caption: 'Reference Documentation',
      description: 'Using Dialogs to interact with users.'
    };

    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }

    FB.ui(obj, callback);
}

自分のサイトで実行すると、コールバックがありません https://www.ipassexam.com/page/fb-test

任意の洞察をいただければ幸いです。

4

6 に答える 6

4

redirect_uri パラメータを取り除きます。これは毎回私にとってうまくいきます:

FB.ui({
    method: 'feed',  
    link: "http://...",
    name: "Some Title",
    caption: "Some Caption",
    description: "Some Description",
    picture: "http://..."
}, function(response) {
    if (response && response.post_id) {
        alert('Post was published.');
    } else {
        alert('Post was not published.');
    }
});

また、コンソールにエラーがないことを確認してください。しかし、とにかくエラーは見られませんでした。

于 2012-12-30T23:38:51.350 に答える
2

問題を理解するのに 2 時間を費やし、解決策は、表示プロパティ (私の場合はポップアップ) について言及することです。

function postToFeed() {

// calling the API ...
var obj = {
  method: 'feed',
  **display: 'popup',**
  link: 'https://developers.facebook.com/docs/reference/dialogs/',
  picture: 'http://fbrell.com/f8.jpg',
  name: 'Facebook Dialogs',
  caption: 'Reference Documentation',
  description: 'Using Dialogs to interact with users.'
};

function callback(response) {
  document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}

FB.ui(obj, callback);

}

ヒント: display が popup として明示的に指定されている場合、redirect_uri は必須ではありません。

于 2013-02-13T18:52:04.560 に答える
1

以下のように、リクエストで「popup」で表示属性を設定してみてください。

FB.ui({
    method: 'feed',  
    link: "http://...",
    name: "Some Title",
    caption: "Some Caption",
    description: "Some Description",
    display: "popup",
    picture: "http://..."
}, function(response) {
    if (response && response.post_id) {
        alert('Post was published.');
    } else {
        alert('Post was not published.');
    }
});

フィード メソッドを使用して投稿しようとすると、FB キャンバス ページ内でこの問題が発生し、常に「未定義」の応答が返されました。上記の属性を試してみましたが、現在は機能しています。

于 2016-01-27T09:07:26.987 に答える
0

おそらく、無名関数をコールバックとして使用してみてください -

FB.ui(obj, function(response) {
  document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
});
于 2012-12-30T22:05:48.340 に答える