How can I download the .zip of my private github repository using cURL on php? -
i want download latest zip version of private github repository i'm working on, , want using php script. however, current php script returning "not found" - i'm guessing have issue curl user/pass setup, can't figure out. current code follows:
$username='xxx'; $password='xxx'; $url='https://github.com/[user]/[reponame]/archive/master.zip'; $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_returntransfer,1); curl_setopt($ch, curlopt_httpauth, curlauth_any); curl_setopt($ch, curlopt_userpwd, "$username:$password"); $result=curl_exec ($ch); file_put_contents('master.zip', $result); curl_close ($ch);
i able work separating login page , file download page 2 requests. following code worked me:
$username='xxx'; $password='xxx'; $url='https://github.com/[user]/[reponame]/archive/master.zip'; $ch = curl_init(); curl_setopt($ch, curlopt_url,'https://github.com'); curl_setopt($ch, curlopt_returntransfer,true); curl_setopt($ch, curlopt_ssl_verifypeer, true); curl_setopt($ch, curlopt_httpauth, curlauth_basic); curl_setopt($ch, curlopt_userpwd, "$username:$password"); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_returntransfer,true); curl_setopt($ch, curlopt_followlocation, true); $result=curl_exec ($ch); curl_close ($ch); file_put_contents('master.zip', $result);
wiki
Comments
Post a Comment