所以我通过上传没有故事的照片来解决它,然后分享它。您可以根据需要分享任意数量的图片,但它将保持为单个帖子。
$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);