知識(shí)
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!
您當(dāng)前位置>首頁(yè) » 新聞資訊 » 公眾號(hào)相關(guān) >
php對(duì)接 微信公眾號(hào) 基本操作
發(fā)表時(shí)間:2020-9-20
發(fā)布人:葵宇科技
瀏覽次數(shù):61
文檔https://developers.weixin.qq.com/doc/offiaccount/Cards_and_Offer/Distributing_Coupons_Vouchers_and_Cards.html
文檔2https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html
文檔3http://caibaojian.com/wxwiki/f5f7a96c36925a7b53a782762d51ebc5c2bb129b.html
簽名校驗(yàn)工具h(yuǎn)ttps://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign
php代碼
<?php
function curl_file_get_contents($durl){
// header傳送格式
/*$headers = array(
"grant_type:client_credential",
"appid:APPID",
"secret:APPSECRET",
);*/
// 初始化
$curl = curl_init();
// 設(shè)置url路徑
curl_setopt($curl, CURLOPT_URL, $durl);
// 將 curl_exec()獲取的信息以文件流的形式返回,而不是直接輸出。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true) ;
// 在啟用 CURLOPT_RETURNTRANSFER 時(shí)候?qū)@取數(shù)據(jù)返回
curl_setopt($curl, CURLOPT_BINARYTRANSFER, true) ;
// 添加頭信息
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// CURLINFO_HEADER_OUT選項(xiàng)可以拿到請(qǐng)求頭信息
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
// 不驗(yàn)證SSL
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
// 執(zhí)行
$data = curl_exec($curl);
// 打印請(qǐng)求頭信息
// echo curl_getinfo($curl, CURLINFO_HEADER_OUT);
// 關(guān)閉連接
curl_close($curl);
// 返回?cái)?shù)據(jù)
var_dump($data);exit();
return $data;
}
curl_file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxc95d4e6b41ae81e8&secret=8ea6c716d28d5f1f94874537815bdde8');
<?php
function curl_file_post_contents($durl, $post_data){
// header傳送格式
/*$headers = array(
"token:1111111111111",
"over_time:22222222222",
);*/
//初始化
$curl = curl_init();
//設(shè)置抓取的url
curl_setopt($curl, CURLOPT_URL, $durl);
//設(shè)置頭文件的信息作為數(shù)據(jù)流輸出
curl_setopt($curl, CURLOPT_HEADER, false);
//設(shè)置獲取的信息以文件流的形式返回,而不是直接輸出。
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//設(shè)置post方式提交
curl_setopt($curl, CURLOPT_POST, true);
// 設(shè)置post請(qǐng)求參數(shù)
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
// 添加頭信息
//curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// CURLINFO_HEADER_OUT選項(xiàng)可以拿到請(qǐng)求頭信息
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
// 不驗(yàn)證SSL
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
//執(zhí)行命令
$data = curl_exec($curl);
// 打印請(qǐng)求頭信息
// echo curl_getinfo($curl, CURLINFO_HEADER_OUT);
//關(guān)閉URL請(qǐng)求
curl_close($curl);
var_dump($data);exit();
//顯示獲得的數(shù)據(jù)
return $data;
}
$post_data = [
'action_name'=>'QR_CARD',
'action_info'=>[
'card'=>[
'card_id'=>'pen536FYRHig_f0P2wrHpxCC3Awg'
]
]
];
$post_data = json_encode($post_data);
curl_file_post_contents('https://api.weixin.qq.com/card/qrcode/create?access_token=37_sCcKc39KJzNQJeTl4VNSHrB7KxbQReg3t3NFOCzU7dFTv8BLGTsDTY75nmQGpgcTDtZh_7rd6S1uaK2z2lFAdAe83eQcpMrgZKz2u5vbjjGEwxNIZzAwdWGe9T-B0apHE8wUKell0xxcxl64MVRhADAQZV',$post_data);
https://www.cnblogs.com/yclimb/p/10066720.html
https://www.cnblogs.com/ldms/p/5241756.html
https://blog.csdn.net/wechatcard/article/details/47980695
獲取ticket,直接get請(qǐng)求即可
https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=37_937j8EQEUGloMOYRSqkO5DtN9O8vZcdAbEdqBKc2VglW6CeThkKA8Ctqs2KHJR548n1XPzZCKrKV-Uk6s5h4ac6MsqkEFNv-Tv00lHsu3ipDnQDmHD3Ar4uJeBogV4UPq0jqAb2-sIbr7l4hDIMcAJAQVZ&type=wx_card
注意jsapi_ticket的生成,別調(diào)到卡券ticket的生成接口了,type要傳"jsapi"
https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi
相關(guān)案例查看更多
相關(guān)閱讀
- 昆明做網(wǎng)站建設(shè)的公司排名
- 云南網(wǎng)絡(luò)推廣
- 網(wǎng)站建設(shè)快速優(yōu)化
- 智慧農(nóng)貿(mào)市場(chǎng)
- 云南省住房建設(shè)廳網(wǎng)站
- 云南小程序開發(fā)公司推薦
- 百度推廣
- 汽車報(bào)廢拆解管理系統(tǒng)
- 云南小程序開發(fā)公司哪家好
- 網(wǎng)站建設(shè)專業(yè)品牌
- 網(wǎng)站建設(shè)制作
- 網(wǎng)站建設(shè)靠譜公司
- 報(bào)廢車拆解回收管理系統(tǒng)
- 網(wǎng)站上首頁(yè)
- 云南網(wǎng)站開發(fā)哪家好
- 網(wǎng)站建設(shè)哪家強(qiáng)
- 網(wǎng)站建設(shè)首選
- 昆明小程序設(shè)計(jì)
- 前端技術(shù)
- 云南網(wǎng)站建設(shè)公司地址
- 網(wǎng)站建設(shè)案例
- 云南軟件定制
- 制作一個(gè)小程序
- 云南網(wǎng)站建設(shè)方案 doc
- 小程序退款
- 網(wǎng)絡(luò)公司排名
- 汽車報(bào)廢系統(tǒng)
- 云南網(wǎng)站建設(shè)方法
- 昆明網(wǎng)站設(shè)計(jì)
- 云南網(wǎng)站優(yōu)化公司