tasianmedia / getYoutube

A simple video retrieval Snippet for MODX Revolution
http://modx.com/extras/package/getyoutube
4 stars 5 forks source link

Curl? #16

Closed matdave closed 6 years ago

matdave commented 6 years ago

Youtube started disliking the way file_get_contents was formatting the URLs today. I changed the references to curl requests and it works again.

e.g.

$json = file_get_contents($videoUrl, false, $context)
    or $modx->log(modX::LOG_LEVEL_ERROR, 'getYoutube() - Video API request not recognised');

to

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $videoUrl);
    curl_setopt($ch,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $json = curl_exec($ch);
    curl_close($ch);
    if(empty($json)){
        $modx->log(modX::LOG_LEVEL_ERROR, 'getYoutube() - Video API request not recognised');
        return;
    }
matdave commented 6 years ago

Looks like the curl was added to getVimeo, so same thing, just with getYoutube instead.

davidpede commented 6 years ago

Yes sorry I commented on the wrong repo! We're adding it now to getYoutube, should be released today/tomorrow

davidpede commented 6 years ago

This issue is solved by https://github.com/tasianmedia/getYoutube/pull/17/commits/2aa1d7b0a171f615cbd10160b6bdcedc6a99e5a5 and included in version 1.2.0-pl