Пример #1
0
 /**
  * 得到用户列表
  *
  * {@see http://mp.weixin.qq.com/wiki/0/d0e07720fc711c02a3eab6ec33054804.html}
  * 
  * @author xjiujiu <*****@*****.**>
  * @access public
  * @param $nextOpenId = '' 下一个OPENID用户编号
  * @return Array {"total":2,"count":2,"data":{"openid":["","OPENID1","OPENID2"]},"next_openid":"NEXT_OPENID"} 
  */
 public function getList($nextOpenId = '')
 {
     $json = HRequest::getContents(strtr(self::$_listUrl, array('{access_token}' => $this->_accessToken, '{next_openid}' => $nextOpenId)));
     $json = json_decode($json, true);
     if (isset($json['errcode']) && 0 < $json['errcode']) {
         throw new HVerifyException('获取用户列表失败,错误信息(' . $json['errcode'] . ':' . $json['errmsg'] . ')');
     }
     return $json;
 }
Пример #2
0
 /**
  * 菜单查询接口
  * 
  * @author xjiujiu <*****@*****.**>
  * @access public
  */
 public function query()
 {
     $json = HRequest::getContents(str_replace('{access_token}', $this->_accessToken, self::$_queryUrl));
     $json = json_decode($json, true);
     if (0 < $json['errcode']) {
         throw new HVerifyException('查询失败!' . $json['errcode'] . ':' . $json['errmsg']);
     }
     return $json;
 }
Пример #3
0
 /**
  * 得到短链接[需要服务号~]
  * {@see http://mp.weixin.qq.com/wiki/10/165c9b15eddcfbd8699ac12b0bd89ae6.html}
  * 
  * @author xjiujiu <*****@*****.**>
  * @access public
  */
 public function getShortUrl($url)
 {
     $response = HRequest::getContents(strtr(self::$_shortUrl, array('{access_token}' => $this->_accessToken, '{url}' => $url)));
     $json = json_decode($response, JSON_UNESCAPED_UNICODE);
     if (0 == $json['errcode']) {
         return $json['short_url'];
     }
     throw new HRequestException('短链接生成失败,' . $response);
 }
Пример #4
0
 /**
  * 刷新得到新的Token
  * 
  * @author xjiujiu <*****@*****.**>
  * @access public
  * @param $token 需要刷新的Tooken
  * @return array
  *   {
  *       "access_token":"ACCESS_TOKEN",
  *           "expires_in":7200,
  *           "refresh_token":"REFRESH_TOKEN",
  *           "openid":"OPENID",
  *           "scope":"SCOPE"
  *   }
  */
 public function refreshToken($token)
 {
     $url = sprintf(self::$_refreshTokenUrl, $this->_appid, $token);
     $json = json_decode(HRequest::getContents($url), true);
     if (isset($json['errcode'])) {
         throw new HVerifyException($json['errmsg']);
     }
     return $json;
 }