Skip to content

Instantly share code, notes, and snippets.

@shierw
Created January 15, 2018 03:29
Show Gist options
  • Save shierw/d1752723ee4519edcf0269662c08c1c0 to your computer and use it in GitHub Desktop.
Save shierw/d1752723ee4519edcf0269662c08c1c0 to your computer and use it in GitHub Desktop.
/**
*$url = 'http://wx.qlogo.cn/mmopen/xu0fLo9waqKSTDO7j0kSO41O5Luq3LB6ozUvY4O7OsXUWNicB49fBs8nGYzoqcwGDARQZHpVuic4JSDngEVjVo10BoiaPd0iciaOb/0';
*$a = curl_file_get_contents($url);
*file_put_contents('uploads/2.jpg', $a);
*/
function curl_file_get_contents($durl){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $durl);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment