如何通过 Facebook API 发布多张照片 [英] How do I can post a multiple photos via 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)
如果将某些照片上传到同一个相册,此分组会由 facebook 自动完成.
This grouping is done by facebook automatically if some photos are uploaded into the same album.
目前您无法通过 Graph API 创建群组相册 - 不支持(截至目前),请参阅 这个错误.
Currently you cannot create an album in a group via Graph API - it is not supported (as of now), see this bug.
但您可以这样做 - 手动创建相册,然后通过-获取album_id
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-
这篇关于如何通过 Facebook API 发布多张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!