与API分享Facebook帖子

时间:2017-09-25 01:52:07

标签: php facebook facebook-graph-api

我可以使用API​​按照Simple example to post to a Facebook fan page via PHP?上的示例发布到我的Facebook,如下所示

$data['picture'] = $image_URL;
$data['link'] = $link_URL;
$data['message'] = $message_TEXT;
$data['caption'] = $caption_TEXT;
$data['description'] = $description_TEXT;
$data['access_token'] = $page_access_token;

$post_url = 'https://graph.facebook.com/'.$page_id.'/feed';

try{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $post_url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($ch);
    curl_close($ch);
}catch (Exception $e) {
    echo 'ERROR '.$e.' in CURL for Facebook posting';
}

如果我们知道帖子的网址(例如https://www.facebook.com/TED/posts/10159368542595652

,是否可以做类似的事情来分享帖子

0 个答案:

没有答案