北京网站外包,广州网站优化网站,电商网站业务流程图,wordpress动漫连载模板微信公众平台现在是越来越强大了,我们可以通过各种api接口来与平台对接获取对应的数据了,下面来看一个由php实现的微信自动获取收货地址api程序,具体如下.关于接口的说明我就不介绍了,在官方可以看到下面只看处理程序.public function get_address_api() {$APPIDC(APPID);$SCRE…微信公众平台现在是越来越强大了,我们可以通过各种api接口来与平台对接获取对应的数据了,下面来看一个由php实现的微信自动获取收货地址api程序,具体如下.关于接口的说明我就不介绍了,在官方可以看到下面只看处理程序.public function get_address_api() {$APPIDC(APPID);$SCRETIDC(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_typecodescopejsapi_addressstate123#wechat_redirect;// snsapi_userinfoHeader(Location: $url);exit;} else {$code $_GET[code];$url https://api.weixin.qq.com/sns/oauth2/access_token?appid.$APPID.secret.$SCRETID.code.$code.grant_typeauthorization_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;}//签名步骤一按字典序排序参数ksort($Parameters);$String $this-formatBizQueryParaMap($Parameters, false);$data[addrsign]SHA1($String);$this-assign(data,$data);}$this-siteDisplay(address_api);}