FB.ui feed not giving a callback

天大地大妈咪最大 提交于 2019-12-04 03:37:22

问题


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 {

                            }
                        }
                    );

回答1:


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



回答2:


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>



回答3:


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.




回答4:


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.




回答5:


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




回答6:


setting a redirect_uri disables the callback



来源:https://stackoverflow.com/questions/8168327/fb-ui-feed-not-giving-a-callback

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