Facebook直接使用PHP发布流

时间:2011-03-14 16:20:16

标签: php facebook facebook-graph-api facebook-php-sdk

我正在尝试在我的Facebook网站壁纸页面上发布流。

到目前为止,我已成功通过我的APP页面发布流,但我不希望通过,我想直接发布。

正如我之前所说,我想在我的Facebook网站壁纸页面上发布,而不是在应用程序墙页面上发布。

我找不到任何有用的东西...我也想用PHP发布如果可能的话......如果不可能我想我将不得不使用js。无论如何我该怎么做?

1 个答案:

答案 0 :(得分:5)

这就是我用PHP做的方式:

 //Note that you will need to have the access token which is what gives permission to write.
 function self_fb_post($to_uid,$acToken) {
    global $fb; //this is the fb object
    $result = false;
    $feed_dir = '/'.$to_uid.'/feed/';  //to the UID you want to send to
    $message_str =  'Why does facebook development not have decent support';
    $msg_body = array('access_token' => $acToken,   
                  'name' => 'My wall post',
                  'message' => $message_str,
                  'caption' => "www.mysite.com",
                  'link' => 'http://www.mysite.com',
                  'description' => 'A wall post which is used to express the frustration of working with crappy facebook developer documentation', 
                  'picture' => 'http://farm6.static.flickr.com/1111/some-pic.jpg',
                  'actions' => array(array('name' => 'My Site',
                              'link' => 'http://www.mysite.com'))
                  );

try {
            //this is the API call that does it all
    $result = $fb->api($feed_dir, 'post', $msg_body);
} 
catch (Exception $e) {       
    $err_str = $e->getMessage();
}


     return $result;
}