public function up(){ $toke = S('token'); if (empty($token)) { $this->getaccess_token(); $toke = S('token'); } $token=json_decode($toke,true)['access_token']; $url="https://api.weixin.qq.com/cgi-bin/media/upload?access_token=".$token."&type=image"; $data['type']='image'; $data['media']='./Data/UploadFiles/product/20181016/1539656106182935.PNG'; $postData=json_encode($data); $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);//流的形势不直接输出 //设置是通过post还是get方法 curl_setopt($ch,CURLOPT_POST,1); //传递的变量 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);//不检查证书 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);//不检查证书名 curl_setopt($ch,CURLOPT_POSTFIELDS,$postData); $da = curl_exec($ch); curl_close($ch); dump($da);die;}
返回却是
string(70) "{"errcode":41005,"errmsg":"media data missing hint: [lVllaa02931335]"}"
微信小程序开发问题解答
微信小程序开发者回答:
解决了PHP7需要new file
本文网址:http://www.91bianli.com/weixinxiaochengxu/39269.html