FB.ui feed 不提供回调

发布于 2024-12-16 02:07:45 字数 662 浏览 10 评论 0原文

我无法从我的 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 {

                            }
                        }
                    );

I am unable to get any feedback from my Facebook FB.UI() method. I am convinced that I am using it correctly, as the actual post does post to my wall, but the callback data is either missing or empty. I am using:

                    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 {

                            }
                        }
                    );

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

笑红尘 2024-12-23 02:07:45

我不确定这个问题是如何解决的,但它确实:)

我清除了缓存并将代码更改为下面的内容并且它起作用了(但是我不相信代码的更改实际上对它:

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");  
    }
 });

I am not sure how this resolved itself, but it did :)

I cleared my cache and changed my code to below and it worked (however I don't believe the change of code actually played any influence on it:

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");  
    }
 });
海夕 2024-12-23 02:07:45

我也遇到了同样的问题,并且一直无法从 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>

I have the same problem and have never been able to get a response from Facebook for the callback function. I don't see anything in console.log or any alerts I insert in the function.

My solution was to put a URL in FB.ui's redirect_uri that goes to an HTML page with self.close (or window.close). The FB.ui popup redirects there after the user's input and immediately closes. Remember to change your FB app's Site URL setting so it matches the domain the file resides on.

Here's my code, tied to my form's submit action. The function(response) callback is still there but not used. If anyone sees a syntax error please comment on it.

    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');
            }
        });

The line of code in self.close.html:

<script type="text/javascript">self.close();</script>
不奢求什么 2024-12-23 02:07:45

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

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

Remove the redirect_uri item and the call back will be fired.

I was facing the same issue a few mins back and realized that removing the redirect_uri solved it.

凝望流年 2024-12-23 02:07:45

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

<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 验证器的原因。

For any who encounter this problem later, I had the exact same issue and fixed it like so:

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

became

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

The post-view-backdrop div was never meant to contain the fb-root, I just missed a close tag.

The problem was improperly formed HTML around my fb-root. I only found this on a hunch, definitely reason to use an html validator.

相权↑美人 2024-12-23 02:07:45

对于 Phonegap 上解决此问题的任何人来说——问题出在 fb connect 插件上。它根本不触发回调。

这是来自 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 程序员,所以我不想解决这个问题,可能必须等到插件完成......

For anyone on Phonegap tackling this issue -- the problem is with the fb connect plugin. It simply doesn't fire the callbacks.

Here's a code snippet from 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 
}

I'm not an Objective C programmer so I'm not trying to solve this, probably have to wait till the plugin is complete...

痞味浪人 2024-12-23 02:07:45

设置redirect_uri会禁用回调

setting a redirect_uri disables the callback

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文