4

我无法从我的 Facebook FB.UI() 方法中获得任何反馈。我确信我正确地使用了它,因为实际的帖子确实发布到了我的墙上,但是回调数据要么丢失要么为空。我在用:

                    FB.ui({
                       method: 'feed',
                        name: 'asd',
                        link: 'asd',
                        picture: '',
                        description: 'asd'
                    }, function(response) {
                        console.log(response);
                            if(response.post_id) {
                               $.post("ajax/wall.php",{wall : 1});
                            } else {

                            }
                        }
                    );
4

6 回答 6

3

我不确定这是如何解决的,但确实如此:)

我清除了我的缓存并将我的代码更改为下面并且它有效(但是我不相信代码的更改实际上对其产生了任何影响:

FB.ui({method: 'feed',name: '',link: '',picture: '',description: 'asd'}, function(data) {
    console.log(response);
    if(data && data.post_id) {
        $.post("ajax/wall.php",{wall : 1});
    } else {
        alert("not sent");  
    }
 });
于 2011-11-19T09:50:57.913 回答
2

我有同样的问题,并且从未能够从 Facebook 获得回调函数的响应。我在 console.log 中看不到任何内容,也看不到我在函数中插入的任何警报。

我的解决方案是在 FB.ui 的 redirect_uri 中放置一个 URL,该 URL 使用 self.close(或 window.close)进入 HTML 页面。FB.ui 弹出窗口在用户输入后重定向到那里并立即关闭。请记住更改您的 FB 应用程序的站点 URL 设置,使其与文件所在的域匹配。

这是我的代码,与表单的提交操作相关联。函数(响应)回调仍然存在但未使用。如果有人看到语法错误,请发表评论。

    FB.ui ({
        method: 'feed',
        name: '',
        link: '',
        picture: '',
        caption: '',
        description: '',
        actions: {name:'',link:''},
        redirect_uri: 'http://.../self.close.html'
        },
        function(response) {
            console.log(response);
            if (response && response.post_id) {
                alert('yes');
                self.close();
            } else {
                alert('else yes');
            }
        });

self.close.html 中的代码行:

<script type="text/javascript">self.close();</script>
于 2012-01-26T20:53:12.520 回答
2

对于以后遇到此问题的任何人,我遇到了完全相同的问题并像这样修复了它:

<div class="post-view-backdrop hide" id='post-view-backdrop'>
    <div id="fb-root"></div>

变成了

<div class="post-view-backdrop hide" id='post-view-backdrop'></div>
<div id="fb-root"></div>

post-view-backdrop div 从来没有打算包含 fb-root,我只是错过了一个关闭标签。

问题在于我的 fb-root 周围的 HTML 格式不正确。我只是凭直觉发现了这一点,这绝对是使用 html 验证器的理由。

于 2012-09-28T14:20:09.497 回答
2

删除该redirect_uri项目,回调将被触发。

几分钟前我遇到了同样的问题,并意识到删除redirect_uri解决了它。

于 2012-09-07T20:45:32.233 回答
1

设置 redirect_uri 会禁用回调

于 2013-03-07T08:47:56.790 回答
1

对于在Phonegap 上解决此问题的任何人——问题在于fb 连接插件。它根本不会触发回调。

这是来自 FacebookConnectPlugin.m 的代码片段:

////////////////////////////////////////////////////////////////////
// FBDialogDelegate

/**
 * Called when the dialog succeeds and is about to be dismissed.
 */
- (void)dialogDidComplete:(FBDialog *)dialog
{
    // TODO
}

/**
 * Called when the dialog succeeds with a returning url.
 */
- (void)dialogCompleteWithUrl:(NSURL *)url
{
    // TODO 
}

/**
 * Called when the dialog get canceled by the user.
 */
- (void)dialogDidNotCompleteWithUrl:(NSURL *)url
{
    // TODO 
}

/**
 * Called when the dialog is cancelled and is about to be dismissed.
 */
- (void)dialogDidNotComplete:(FBDialog *)dialog
{
    // TODO 
}

我不是Objective C程序员,所以我不想解决这个问题,可能必须等到插件完成......

于 2012-08-12T06:57:58.767 回答