欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php版微信自動獲取收貨地址api用法示例

 更新時間:2016年09月22日 12:05:30   作者:smiling  
這篇文章主要介紹了php版微信自動獲取收貨地址api用法,結(jié)合實例形式分析了php版微信API接口調(diào)用與使用技巧,需要的朋友可以參考下

本文實例講述了php版微信自動獲取收貨地址api用法。分享給大家供大家參考,具體如下:

微信公眾平臺現(xiàn)在是越來越強(qiáng)大了,我們可以通過各種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');
}

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP微信開發(fā)技巧匯總》、《PHP編碼與轉(zhuǎn)碼操作技巧匯總》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語法入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論