国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

微信自動獲取收貨地址api程序

2024-05-04 21:49:59
字體:
供稿:網(wǎng)友

微信公眾平臺現(xiàn)在是越來越強大了,我們可以通過各種api接口來與平臺對接獲取對應(yīng)的數(shù)據(jù)了,下面來看一個由php實現(xiàn)的微信自動獲取收貨地址api程序,具體如下.

關(guān)于接口的說明我就不介紹了,在官方可以看到下面只看處理程序.

public function get_address_api(){
 $APPID=C('APPID');
 $SCRETID=C('SCRETID');
 if (!isset($_GET['code']))
 {
 $backurl = $this->get_url();
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$APPID."&redirect_uri=".urlencode($backurl)."&response_type=code&scope=jsapi_address&state=123#wechat_redirect"; // snsapi_userinfo
Header("Location: $url");
exit;
}else
{
$code = $_GET['code'];
$url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$APPID."&secret=".$SCRETID."&code=".$code."&grant_type=authorization_code";
$re = file_get_contents($url);
$rearr = json_decode($re,true);
$backurl = $this->get_url();
$openid = $rearr['openid'];
$unionid = $rearr['unionid'];
$asstoken = $rearr['access_token'];
S('jsapi_address_token'.$openid,$asstoken,7200);
 
$data['appid']=$APPID;
$data['url']=$backurl;
$data['timestamp']=time();
$data['timestamp']= (string)($data['timestamp']);
$data['noncestr']=$this->getRandStr(10);
$data['accesstoken']=$asstoken;
 
foreach ($data as $k => $v)
 {
 $Parameters[$k] = $v;
 }
 //簽名步驟一:按字典序排序參數(shù)
 ksort($Parameters);
 $String = $this->formatBizQueryParaMap($Parameters, false);
$data['addrsign']=SHA1($String);
$this->assign('data',$data);
}
$this->siteDisplay('address_api');
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 莱阳市| 门头沟区| 房山区| 奇台县| 奉节县| 射洪县| 尼玛县| 鄂托克前旗| 东阳市| 来凤县| 钦州市| 嘉黎县| 平乐县| 宿州市| 晋州市| 西昌市| 济南市| 房产| 仁怀市| 舞阳县| 佛学| 平度市| 桂阳县| 乌鲁木齐县| 邓州市| 长春市| 张家川| 宁城县| 获嘉县| 旺苍县| 大渡口区| 文登市| 永顺县| 岳西县| 双城市| 丹凤县| 浠水县| 永宁县| 芜湖市| 绥阳县| 山丹县|