国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php - 微信 二維碼生成接口 全是亂碼什么問題
巴扎黑
巴扎黑 2017-04-10 17:11:01
0
1
529

微信 二維碼生成接口 全是亂碼什么問題

<?php
/*
 *獲取微信token
*/
$appid="wx78478e595939c538";
$secret="5540e8ccab4f71dfad752f73cfb85780";
$url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret."";

//$token=(array)json_decode(file_get_contents($url));

$output=gettoken($url);

$token=(array)json_decode($output);

$token=$token['access_token'];
//print_r($token);
//echo $token['access_token'];
$date='{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 100}}}';
$erweimaurl="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$token."";
$erweimaarr=(array)json_decode(getshort($date,$erweimaurl));
//echo $erweimaarr['ticket'];

$huanurl="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".$erweimaarr['ticket']."";
echo gettoken($huanurl);

function gettoken($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22");
    curl_setopt($ch, CURLOPT_ENCODING ,'gzip'); //加入gzip解析
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

function getshort($data,$url){
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $tmpInfo = curl_exec($ch);
     if (curl_errno($ch)) {
      return curl_error($ch);
     }
     curl_close($ch);
     return $tmpInfo;
}
?>

巴扎黑
巴扎黑

reply all(1)
大家講道理

檢查 頁面輸出的header 的 content-type 的類型

還有,提醒一下你這樣暴露appid和secret真的好嗎

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template