日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

微信小程序 最全 生成带参数二维码

發(fā)布時(shí)間:2023/12/31 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微信小程序 最全 生成带参数二维码 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

摸索了幾天終于完成了,接口A B C 通用 ,接口B只能生成已發(fā)布的小程序 ?

?

$appid='APPid';

$secret='你的小程序秘鑰';


$tokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;






$html = file_get_contents($tokenUrl); ?
$arr =json_decode($html,true);
// echo $arr['access_token'];


$access_token=$arr['access_token'];


? ? //場(chǎng)景1
? ? // $path="pages/index/index?id=1";
? ? // $width='430';
? ? // $post_data='{"path":"'.$path.'","width":'.$width.'}';
? ? // $url="https://api.weixin.qq.com/wxa/getwxacode?access_token=".$access_token;




? ? // 場(chǎng)景2
? ? // $page="pages/index/index";
? ? // $scene="id=1";
? ? // $width='430';
? ? // $post_data='{"scene":"'.$scene.'","page":"'.$page.'","width":'.$width.'}';
? ? // $url="https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$access_token;




? ? // 場(chǎng)景3
? ? // $path="pages/index/index?id=1";
? ? // $width='430';
? ? // $post_data='{"path":"'.$path.'","width":'.$width.'}';
? ? // $url="https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=".$access_token;






? ? $result=api_notice_increment($url,$post_data);


// print_r($result);
// exit();


$base64_image_content =data_uri($result,'image/png'); ?




//匹配出圖片的格式
if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
$type = $result[2];
$new_file = "nusoap/".date('Ymd',time())."/";
if(!file_exists($new_file))
{
//檢查是否有該文件夾,如果沒有就創(chuàng)建,并給予最高權(quán)限
mkdir($new_file, 0700);
}
$new_file = $new_file.time().".{$type}";
if (file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_image_content)))){
echo '新文件保存成功:', $new_file;
}else{
echo '新文件保存失敗';
}
}


? exit();


function api_notice_increment($url,$data){


? ? $ch = curl_init();
? ? $header = "Accept-Charset: utf-8";
? ? 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($curl, CURLOPT_HTTPHEADER, $header);


? ? 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);
? ? ? ?// return $tmpInfo;
? ? // // ? ? var_dump($tmpInfo);
? ? // // ? ?exit;
? ? if (curl_errno($ch)) {
? ? ? return false;
? ? }else{
? ? ? // var_dump($tmpInfo);
? ? ? return $tmpInfo;
? ? }
? }




function data_uri($contents, $mime) ?
{ ?
??
? ? $base64 ? = base64_encode($contents); ?
? ? ??
? ? return ('data:' . $mime . ';base64,' . $base64); ?

} ?

?

?

?

?

y有問題 可以留言 或者 加微信 ai_002

總結(jié)

以上是生活随笔為你收集整理的微信小程序 最全 生成带参数二维码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。