最新消息: 新版网站上线了!!!

php微信公众号读取用户上传的图片,并保存到网站



public function actionT($mid){
  //mid的获取
    $images = trim($weixin->msg->MediaId);
        $data = array(
            'grant_type'=>'client_credential',
            'appid'=>'wxe50cexxxc9',
            'secret'=>'6912e6ee67e4xxxxxd27e4ec87'
        );
        $file = self::getcurl($url,$data);
 
        $josn = json_decode($file,true);
        $token = $josn['access_token'];
        file_put_contents('./uploads/xx.jpg', file_get_contents($urls));
        return true;
    }
public function getcurl($url,$data=array()){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
// 这一句是最主要的
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch) ;
    return $response;
}

转载请注明:谷谷点程序 » php微信公众号读取用户上传的图片,并保存到网站