如何通过Facebook API发布多张照片?
现在我发布一张照片到墙上:
Now I posting a single photo to wall like this:
$response = $facebook->api("/$group_id/photos", "POST", array(
'access_token=' => $access_token,
'message' => 'This is a test message',
'url' => 'http://d24w6bsrhbeh9d.cloudfront.net/photo/agydwb6_460s.jpg',
)
);
它可以正常工作,但我可以以某种方式发布多张照片,如下所示:
It works fine, but can I somehow post a multiple photos, something like this:
提前感谢
您可以按照以下提到批量请求: https://stackoverflow.com/a/11025457/1343690
You can make batch requests as mentioned here: https://stackoverflow.com/a/11025457/1343690
但它的简单循环浏览图像并直接发布。
But its simple to loop through your images and publish them directly.
foreach($photos as $photo)
{
//publish photo
}
编辑:
(关于墙上的照片分组)(regarding grouping of photos on wall)
如果某些照片被上传到相同的相册
This grouping is done by facebook automatically if some photos are uploaded into the same album.
目前,您无法在群组通过Graph API - 它不支持(截至目前),请参阅此错误。
但是您可以手动创建相册,然后获取 album_id
by- \GET / {group-id} / albums
,然后使用 album_id
而不是 group_id
-
But you can do this - create an album manually, then get the album_id
by-
\GET /{group-id}/albums
, then use the the code with album_id
instead of group_id
-
foreach($photos as $photo){
$facebook->api("/{album-id}/photos", "POST", array(
'access_token=' => $access_token,
'name' => 'This is a test message',
'url' => $photo
)
);
}
我已经测试了,请看结果 -
I've tested it, see the result-