开发者

FB.ui bug, can't use the 'feed' method

I have a bug while using FB.ui, although I'm doing everything by the book.

I want to a button so users can share the page on their wall.

When I click the button, I get a facebook popup window that says:

An error occurred, Please try again later.

Can you see what's wrong?

Thanks!

Here's my code:

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init
({
    appId:'MYAPPID', 
    status:true, 
    cookie: true, 
    xfbml:true
});
function shareProject2()
{
     FB.ui(
               {
                 method: 'feed',
                 name: 'Facebook Dialogs',
                 link: 'http://developers.facebook.com/docs/reference/dialogs/',
                 picture: 'http://fbrell.com/f8.jpg',
                 caption: 'Reference Documentation',
                 description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
                 message: 'Facebook Dialogs are easy!'
               },
               function(response) {
                 if (response && response.post_id) {
                   getPermission();
                 } else {
                   alert('Post was not published.');
                 }
               });
     return false;
} 


</script&开发者_StackOverflow中文版gt;

<a href="#" onclick="shareProject2();" >Share</a>


Have you tried passing the session from the server to the client JavaScript

This would be done in php as:

<?php
require 'facebook.php';

$facebook = new Facebook(array(
    'appId' => $appId,   // Your App Id
    'secret' => $secret, // Your App Secret
    'cookie' => true,
));

$session = $facebook->getSession();
?>

<script>
    FB.init
    ({
        appId:'MYAPPID',<?php
        echo (!empty($session)) ? 'session: ' . json_encode($session) . ',' : '' ?>
        status:true, 
        cookie: true, 
        xfbml:true
    });

...

</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜