0

我正在使用此代码将图片发布到 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);
4

1 回答 1

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);
于 2013-04-10T09:58:26.520 回答