How do I can post a multiple photos via Facebook API

前端 未结 5 1961
难免孤独
难免孤独 2020-11-29 10:26

Now I posting a single photo to wall like this:

$response = $facebook->api(\"/$group_id/photos\", \"POST\", array(
    \'access_token=\' => $access_to         


        
5条回答
  •  生来不讨喜
    2020-11-29 11:05

    Actually you can upload a multi story photo(I did it using Graph Api and PHP) but the problem comes if you need scheduled this post.Your post is schedule but also it shows on the page's feed.

    P.S. I'm using Graph Api v2.9

    PHP Code

    $endpoint = "/".$page_id."/photos";
    
    foreach ($multiple_photos as $file_url):
    array_push($photos, $fb->request('POST',$endpoint,['url' =>$file_url,'published' => FALSE,]));
    endforeach;
    
    $uploaded_photos = $fb->sendBatchRequest($photos,  $page_access_token); 
    
    foreach ($uploaded_photos as $photo):
    array_push($data_post['attached_media'], '{"media_fbid":"'.$photo->getDecodedBody()['id'].'"}');
    endforeach;
    
    $data_post['message'] = $linkData['caption'];
    
    $data_post['published'] = FALSE;
    
    $data_post['scheduled_publish_time'] = $scheduled_publish_time;
    
    $response = $fb->sendRequest('POST', "/".$page_id."/feed", $data_post, $page_access_token);
    
    $post_id = $cresponse->getGraphNode()['id'];
    

提交回复
热议问题