本地缓存微信头像

1.php获取微信头像

$target=BASE_UPLOAD_PATH.'/'.ATTACH_AVATAR."/avatar_$result.jpg";
$url=$reheadimgurl;
$ch = curl_init();
$httpheader = array(
    'Host' => 'wx.qlogo.cn',
    'Connection' => 'keep-alive',
    'Pragma' => 'no-cache',
    'Cache-Control' => 'no-cache',
    'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8',
    'User-Agent' => 'Mozilla/5.0 (windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
    'Accept-Encoding' => 'gzip, deflate, sdch',
    'Accept-Language' => 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4'
);
$options = array(
    CURLOPT_HTTPHEADER => $httpheader,
    CURLOPT_URL => $url,
    CURLOPT_TIMEOUT => 5,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array( $ch , $options );
$result1 = curl_exec( $ch );
curl_close($ch);
file_put_contents( $target, $result1 );


打赏

看恩吧
网站不承担任何有关评论的责任
  • 最新评论
  • 总共条评论
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦