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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With