I'm using the following lines of code (PHP) after successfuly retriving the media URL and then storing it in the $mediaURL variable for the file request, but it's returning an empty string. Already tried with postman and it returns a 500 internal server error...
** Edited **
self::writeLog('Media URL: '.$mediaURL);
self::writeLog('Preparing to download media - id: '.$media_id);
$curl = curl_init($mediaURL);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Authorization: Bearer ".self::$auth_token,
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
if (($resp = curl_exec($curl)) === false) {
self::writeLog('cURL Error: '.curl_error($curl));
} else if ($resp == '') {
self::writeLog('Empty string.');
self::writeLog('URL: '.$mediaURL);
self::writeLog('Headers: '.$headers[0]);
} else {
self::writeLog($resp);
}
- writeLog is just a method that I use to write these messages on a txt file.