3

Query in PHP using API v2.4

When I try to upload a video using AdVideo class as shown below,

  $time_limit = ini_get('max_execution_time');
  set_time_limit(0);
  $video = new AdVideo(null, $account_id);
  $video->{AdVideoFields::NAME} = *name*;
  $video->{AdVideoFields::SOURCE} = *video_path*;
 try {
     $video->create();
 } catch (\FacebookAds\Http\Exception\RequestException $e) {
     echo "<script>alert('" . $e->getErrorUserMessage() . "')</script>";
     set_time_limit($time_limit);
     return;
 }
 set_time_limit($time_limit);

Result:

I get the following exception -
'Operation timed out after 60000 milliseconds with 0 bytes received'

The video I upload is around 20MB and it would take more time to upload. How to handle this? Is there a way we can show the progress of upload? Does this class support chunked upload ?

Tried set_time_limit(0); but no help.

  • 2
    The API supports chunked upload, but not sure about that 'Ads' SDK - have you ruled out the 60 second timeout being on your side, BTW? If so, then using chunked upload should work for you – Igy Aug 07 '15 at 21:15

1 Answers1

1

This looks like you're hitting the CURL timeout which is 60 by default within the SDK.

You can use the following code to change the timeout to be unlimited:

Api::instance()
  ->getHttpClient()
  ->getAdapter()
  ->getOpts()
  ->offsetSet(CURLOPT_TIMEOUT, 0);
Paul Bain
  • 4,364
  • 1
  • 16
  • 30