在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
function ppost($url,$arr){ $post_data = json_encode($arr); $url=$url; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//这里也是那个是否接收返回值的设置 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); $result = curl_exec($ch); curl_close($ch); return $result; } //将二进制以图片存入硬盘 function toimg($aa,$path,$filename){ //将二进制转为图片 $imgDir = $path; $filename=$filename;///要生成的图片名字 $xmlstr = $aa; if(empty($xmlstr)) { $xmlstr = file_get_contents('php://input'); } $jpg = $xmlstr;//得到post过来的二进制原始数据 if(empty($jpg)) { echo 'nostream'; exit(); } $file = fopen("./".$imgDir."/".$filename,"w");//打开文件准备写入 fwrite($file,$jpg);//写入 fclose($file);//关闭 $filePath = './'.$imgDir."/".$filename; //图片是否存在 if(!file_exists($filePath)) { echo 'createFail'."---".$filePath; exit(); } } $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=TOKEN"; $data['scene'] = "666"; //二维码参数 $data['width'] = "100"; //$data['page'] = "pages/index/index"; $aa = ppost($url,$data); toimg($aa,'Public/tk_qrcode',time().".jpg");
|
请发表评论