Cómo download un github json

Tengo un problema, intentaría download todo el json generado por esta URL

https://api.github.com/repos/xxxx/xxxx/contents/xxxxxxx?ref=master 

Tengo un resultado json así

 [ { "name": "xxxx.png", "path": "xxxx/xxxx.png", "sha": "8b33da362caab310626daa2b70b232a98b38c6db", "size": 136356, "url": "https://api.github.com/repos/xxxx/xxxx/contents/xxxx/xxxx.png?ref=master", "html_url": "https://github.com/xxxx/xxxx/blob/master/xxxx/xxxx.png", "git_url": "https://api.github.com/repos/xxxx/xxxx/git/blobs/8b33da362caab310626daa2b70b232a98b38c6db", "download_url": "https://raw.githubusercontent.com/xxxx/xxxx/master/ModuleInfosJson/xxxx.png", "type": "file", "_links": { "self": "https://api.github.com/repos/xxxx/xxxx/contents/xxxx/xxxx.png?ref=master", "git": "https://api.github.com/repos/xxxx/xxxx/git/blobs/8b33da362caab310626daa2b70b232a98b38c6db", "html": "https://github.com/xxxx/module_apxxxx/blob/master/xxxx/xxxx.png" } } ] 

Escribo esto pero no funciona y tengo este post: no se pudo abrir la secuencia: ¡Falló la request HTTP! HTTP / 1.0 403 prohibido

 Warning: fopen([{"name":"xxxxxx.png","path":"xxxxxx/xxxxxxx.png","sha":".............. 

Mi directory está en 777.

  $json = @file_get_contents($this->GetGithubRepo() . '/' . $module_name . '/contents/' . $this->ModuleInfosJson . '?ref=master', true, $this->context ); file_put_contents(OSCOM::getConfig('dir_root', 'Shop') . $this->ModuleInfosJson . '/Cache/' . $module_name . '.json', fopen($json, 'r')); 

pero si escribo el código así, está bien, pero necesito la información como sha, git …, eso es lo que necesito, no en este caso.

  $download = 'https://raw.githubusercontent.com/ClicShoppingAddsOn/' . $module_name . '/master/' . $this->ModuleInfosJson . '/' . $module_name . '.json'; file_put_contents(OSCOM::getConfig('dir_root', 'Shop') . $this->ModuleInfosJson . '/Cache/' . $module_name . '.json', fopen($download, 'r')); 

Gracias.

Encontré una solución

  $local_file = OSCOM::getConfig('dir_root', 'Shop') . $this->ModuleInfosJson . '/Cache/' . $module_name . '.json'; $remote_file = $this->GetGithubRepo() . '/' . $module_name . '/contents/' . $this->ModuleInfosJson . '?ref=master'; $ch = curl_init(); $fp = fopen ($local_file, 'w+'); $ch = curl_init($remote_file); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 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_TIMEOUT, 50); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_exec($ch); curl_close($ch); fclose($fp); 
    Intereting Posts