dqhdpppm02183 2014-04-11 14:37
浏览 97
已采纳

如何通过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:

enter image description here

Thanks in advance!

  • 写回答

5条回答 默认 最新

  • doufei9946 2014-04-11 14:47
    关注

    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
    }
    


    Edit:

    (regarding grouping of photos on wall)

    This grouping is done by facebook automatically if some photos are uploaded into the same album.

    Currently you cannot create an album in a group via Graph API - it is not supported (as of now), see this bug.

    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-

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 阿里云python代码求解
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路