<?php include "../inc/odbc.php"; ?>
|
<?php
|
$QR_type = !empty($_REQUEST["QR_type"])?$_REQUEST["QR_type"]:"1";
|
|
//生成用户个人二维码参数
|
$UserID = !empty($_REQUEST["UserID"])?$_REQUEST["UserID"]:"";
|
if ( !empty($UserID) ) {
|
$method="UserCodeScene";
|
$arr = array('method'=>$method,"APPID"=>$APPID,"UserID"=>$UserID,"UnixTime"=>time());
|
ksort($arr);
|
$i=0;
|
$stringA='';
|
$content='';
|
foreach($arr as $k=>$v){
|
$stringA=$stringA.$k.$v;
|
$content.="&".$k."=".$v;
|
}
|
$stringSignTemp=$stringA.$APPSECRET;
|
$stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
|
$sign=MD5($stringSignTemp);
|
//echo $stringSignTemp.",Sign:".$sign."<br>";
|
$content = 'Sign='.$sign.$content;
|
$api_url='https://api.966120.com.cn/v3/User/?'.$content;
|
//echo $api_url;exit;
|
$api_url=str_replace(" ", "%20", $api_url);
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$result = $api_info["result"];
|
if ($result==1){
|
$UserScene = $api_info["scene"];
|
}
|
//echo $UserScene;exit;
|
}
|
|
if ($QR_type=="1") {
|
//生成小程序码
|
$method="weixin_Appid";
|
$arr = array('method'=>$method,"APPID"=>$APPID,"UnixTime"=>time());
|
ksort($arr);
|
$i=0;
|
$stringA='';
|
$content='';
|
foreach($arr as $k=>$v){
|
$stringA=$stringA.$k.$v;
|
$content.="&".$k."=".$v;
|
}
|
$stringSignTemp=$stringA.$APPSECRET;
|
$stringSignTemp=str_replace(" ", "%20", $stringSignTemp);
|
$sign=MD5($stringSignTemp);
|
//echo $stringSignTemp.",Sign:".$sign."<br>";
|
$content = 'Sign='.$sign.$content;
|
$api_url='https://api.966120.com.cn/v3/weixin/?'.$content;
|
//echo $api_url;exit;
|
$api_url=str_replace(" ", "%20", $api_url);
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$result = $api_info["result"];
|
if ($result==1){
|
$wx_Name = $api_info["weixin_Name"];
|
$wx_appid = $api_info["wx_APPID"];
|
$wx_APPSECRET = $api_info["wx_APPSECRET"];
|
$wx_access_token = $api_info["access_token"];
|
$jsapi_ticket = $api_info["jsapi_ticket"];
|
$mch_id = $api_info["mch_id"];
|
$mch_key = $api_info["mch_key"];
|
}
|
//echo $wx_appid;exit;
|
if(!empty($wx_access_token)){
|
$width = !empty($_REQUEST["width"])?$_REQUEST["width"]:"430";
|
$ma_url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=$wx_access_token";
|
$path = !empty($_REQUEST["path"])?str_replace("|","&",$_REQUEST["path"]):"pages/index/index";
|
$page = explode("?",$path)[0];
|
$scene = !empty($_REQUEST["scene"])?$_REQUEST["scene"]:"0";
|
if (empty($scene) and !empty($UserScene)){$scene=$UserScene;}
|
$send = array(
|
"page"=>$page,
|
"width"=>$width,
|
"scene"=>$scene
|
);
|
// var_dump($send);exit;
|
$send = json_encode($send);
|
// var_dump($send);exit;
|
$ch = curl_init();//初始化curl
|
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
curl_setopt($ch, CURLOPT_URL, $ma_url);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
|
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$send);
|
|
$data_save = curl_exec($ch);//运行curl
|
// var_dump($data_save);exit;
|
|
|
|
curl_close($ch);
|
if(!empty($_REQUEST["base"])){
|
echo "data:image/jpeg;base64,".base64_encode($data_save);
|
}else{
|
header("content-type: image/jpeg");
|
echo $data_save;
|
}
|
// header("content-type: image/jpeg");
|
|
|
|
}
|
}elseif ($QR_type=="2") {
|
//生成公众号带参数二维码
|
$QR_Key = !empty($_REQUEST["QR_Key"])?$_REQUEST["QR_Key"]:"0";
|
if(!empty($QR_Key)){
|
$api_url='https://wx.966120.com.cn/wx_QRapi.asp?QR_type=4&QR_Key='.$QR_Key;
|
//echo $api_url;exit;
|
$api_info=file_get_contents($api_url);
|
echo $api_info;
|
}
|
}
|
|
|
|
|
|
?>
|