好吧,我找不到一种方法来使用link_post()函数发布到一个fanpage,所以我决定改变流的形状。以一种看起来相同的方式发布结果。为了得到同样的效果,我不得不围绕变量跳很多舞,但效果很好。在本例中,我必须获取“描述”元标记、页面内容中的第一个图像和页面标题。
我希望这能帮助别人:
$title = 'Title of the article, or the title of your webpage';
$message = 'Caption that will go with the link, from the user';
$description = 'I put what would have been in the description metatag, which is what the post link seems to grab';
$fb_thumbnail = ''; // a link to the first image in your article
$target_id = 'XXXXXX'; // the id of the fan page you want to post to
$attachment = array( 'name' => $title,
'href' => 'http://'.$url,
'description' => $description,
'media' => array(array('type' => 'image',
'src' => $fb_thumbnail,
'href' => 'http://'.$url))); // I would get an error with the HREF but that's because I wasn't including the "http://" bit in the link
$attachment = json_encode($attachment);
$facebook->api_client->stream_publish($message, $attachment,"",$target_id);