FB.ui feed not giving a callback

走远了吗. 提交于 2019-12-01 19:47:12

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

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>
Bharath Parlapalli

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.

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.

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...

setting a redirect_uri disables the callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!