开发者

Facebook offline wall posting

I do have website for Restaraunt which has facebook registration module for the users to register. There are two kinds of user for my website, one is normal registered user and second user is Facebook Registered user. This seems to work correctly upto this moment.In the website, all the users are allowed to post their own review about hotels,favorites etc.

I need a way for automatic sharing of reviews, likes and favourites to the users Facebook wall in the Facebook website by using there Fb details(Fbid) that i have stored in my database. Each the reviews need to be posted to the FB wall using his/her own fb-id without fb login. Is there is an开发者_运维百科y php-Facebook plugin /JSSDK to meet this requirement?

I have used the following lines of library codes, but nothing happend yet now.

require_once 'facebook.php';
$api_key = 'yyyyyyyyyyyyyyyyyyy';
$secret = 'xxxxxxxxxxxxxxxxxxxx';
$name = 'Publish feed code example';
$id='100001948358224';
$name_href = 'http://forum.developers.facebook.com/viewtopic.php?id=44721';
$caption = 'A simple code caption text';
$description = 'The new Facebook.streamPublish code to pop up a publish feed form';
$img_1 = 'http://www.applications.junkieyard.com/fbfgsfy/images/smileys/smiley-09-05.png';
$img_1_href = 'http://apps.facebook.com/fbfgsfy/profile.php';
$action_links_text = 'Facebook?';
$action_links_href = 'http://www.facebook.com/';
$attachment = array('name' => $name, 'href' => $name_href, 'caption' => $caption, 'description' => $description, 'media' => array(array('type' => 'image', 'src' => $img_1, 'href' => $img_1_href)));
$action_links = array(array('text' => $action_links_text, 'href' => $action_links_href));
if ($id) {

    $target_id = $id;
    ?>
    <script>
        var message = "";
        var attachment = <?=json_encode($attachment)?>;
        var action_links = <?=json_encode($action_links)?>;
        var target_id = <?=$target_id?>;
        alert(Facebook.streamPublish(message, attachment, action_links, target_id));
    </script>
    <?php
}

?>


offline_access is no longer used in facebook, the new way is the Expiration Time of the TOKEN through New Endpoint read more at https://developers.facebook.com/roadmap/offline-access-removal/


You would need to request the publish_stream and offline_access permissions from the user to post on their wall when their session is not active.

To post on their wall programmatically, use the feed method of FB.ui

FB.ui(
    {
        method: 'feed',
        name: 'Restaurant App',
        link: 'http://apps.facebook.com/yourapp',
        caption: 'Check out my review',
        description: 'The most awesome restaurant ever.',
        message: 'Check out this awesome app'
    },
    function(response) {
        console.log(response);
        console.log(response.post_id);
        if (response && response.post_id) {
            console.log('Post was published.');
        } else {
            console.log('Post was not published.');
        }
    }
    );

To see the above code in action, check it out on the demo app FBRell

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜