状态发布数组中的用户对象语法

时间:2012-02-16 01:31:55

标签: facebook object

使用Facebook API在状态发布数组中引用特定用户对象的语法是什么?以下是我的内容。

$status = $facebook->api('/<PAGE_ID>/feed', 'POST', array(
'from' =>       "id": "<PAGE_ID>", "name": "<PAGE_NAME>",
'title' =>  'This is the title',
'message' =>    'This is the message',
'description'=> 'This is the description',
'caption' =>    'This is the caption',
'link' => 'http://www.thisisthelink.com'
));

除FROM字段外,一切正常。

2 个答案:

答案 0 :(得分:0)

/<PAGE_ID>/feed不接受from参数,只有http://developers.facebook.com/docs/reference/api/page/#posts中的参数可供指定。

另请参阅:http://facebook.stackoverflow.com/q/691425/251311

答案 1 :(得分:0)

这很有效。我把帖子的参数和feed的参数混淆了。

<?

require_once 'fb_access.php';

$user = $facebook->getUser();

if ($user) {
  try {
    $page_id = '****NOT*PHP*CODE*PLACEHOLDER*FOR*PAGE*ID*DUH****';
    $page_info = $facebook->api("/$page_id?fields=access_token");
    if( !empty($page_info['access_token']) ) {
        $args = array(
            'access_token'  =>  $page_info['access_token'],
            'message'       =>  'This is the message',
            'link'          =>  'http://thisisthelink',
            'caption'       =>  'This is the caption',
            'description'   =>  'This is the description',
        );
        $post_id = $facebook->api("/$page_id/feed","post",$args);
    }
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}
?>