图表api - 发布图像时的个人故事

时间:2013-04-09 14:48:19

标签: php facebook-graph-api

我正在使用此代码将图片发布到FB墙。但是,当我发布4张或更多图片时,故事就会崩溃并显示“(页面名称)将4张照片添加到相册......”......有没有办法为每张照片创作个人故事?

$postdata = http_build_query(
  array(
    'access_token' => $token,
    'message' => $mes,
    'url' => $img
  )
);
$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result = file_get_contents('https://graph.facebook.com/'.$album_id.'/photos', false, $context);

1 个答案:

答案 0 :(得分:0)

所以我通过上传没有故事的照片解决了它,然后分享它。您可以根据需要分享任意数量的图片,但它仍然是单个帖子。

$postdata = http_build_query(
  array(
    'access_token' => $token,
    'message' => $mes,
    'url' => $img,
    'no_story' => '1'
  )
);
$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result = json_decode(file_get_contents('https://graph.facebook.com/'.$album_id.'/photos', false, $context));

$postdata = http_build_query(
  array(
    'access_token' => $token,
    'is_hidden' => 'true'
  )
);
$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result2 = file_get_contents('https://graph.facebook.com/'.$result->id, false, $context);

$postdata = http_build_query(
  array(
    'access_token' => $token,
    'link' => 'http://www.facebook.com/photo.php?fbid='.$result->id
  )
);
$opts = array('http' =>
  array(
    'method'  => 'POST',
    'header'  => 'Content-type: application/x-www-form-urlencoded',
    'content' => $postdata
  )
);
$context  = stream_context_create($opts);
$result3 = file_get_contents('https://graph.facebook.com/'.$id.'/feed', false, $context);