示例#1
0
文件: menu.php 项目: elmoy/wenheyou
 /**
  * 获取菜单
  */
 public function get()
 {
     $host = 'https://api.weixin.qq.com/cgi-bin/menu/get?access_token=%s';
     $url = sprintf($host, $this->get_accesstoken());
     $info = \Core\Curl::get($url);
     $response = json_decode($info->response, true);
     if ($response['errcode'] == 0) {
         return $response;
     }
     return false;
 }
示例#2
0
文件: oauth.php 项目: elmoy/wenheyou
 /**
  * 获取用户授权的token
  * @param string $code
  * @param int $corp_agent_id
  */
 public function get_userid($code)
 {
     $host = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=%s&code=%s&agentid=%s";
     $url = sprintf($host, $this->get_accesstoken(), $code, $this->corpagentid);
     $info = \Core\Curl::get($url);
     $response = json_decode($info->response, true);
     if (isset($response['UserId'])) {
         return $response['UserId'];
     }
     return false;
 }
示例#3
0
文件: oauth.php 项目: elmoy/wenheyou
 /**
  * 获取用户基本信息
  * @param string $access_token
  * @param string $open_id
  */
 public function user_info($key = null)
 {
     if (empty($this->user_info)) {
         $host = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";
         $url = sprintf($host, $this->user_accesstoken['access_token'], $this->user_accesstoken['openid']);
         $info = \Core\Curl::get($url);
         $response = json_decode($info->response, true);
         if (isset($response['nickname'])) {
             $this->user_info = $response;
         }
     }
     if (!is_null($key) && isset($this->user_info[$key])) {
         return $this->user_info[$key];
     }
     return $this->user_info;
 }
示例#4
0
文件: common.php 项目: elmoy/wenheyou
 private function get_jsapi_ticket($key = 'ticket', $default = null)
 {
     \Core\Cache::init_config_params();
     $this->ticket = \Core\Cache::get('jsapi_ticket');
     if (empty($this->ticket)) {
         $host = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=%s";
         $url = sprintf($host, $this->get_accesstoken());
         $info = \Core\Curl::get($url);
         $respone = json_decode($info->response, true);
         if (isset($respone['ticket'])) {
             $this->ticket = $respone;
         }
         \Core\Cache::set('jsapi_ticket', $respone);
     }
     if (!isset($this->ticket[$key])) {
         $this->ticket[$key] = $default;
     }
     return $this->ticket[$key];
 }
示例#5
0
文件: common.php 项目: elmoy/wenheyou
 /**
  * 获取关注用户的信息,未关注用户获取不到个人信息
  */
 public function subscribe_user_info($open_id)
 {
     $host = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN";
     $url = sprintf($host, $this->get_accesstoken(), $open_id);
     $info = \Core\Curl::get($url);
     $response = json_decode($info->response, true);
     if (!empty($response['subscribe'])) {
         return $response;
     }
     return NULL;
 }
示例#6
0
文件: common.php 项目: elmoy/wenheyou
 /**
  * 请求token
  */
 public function get_accesstoken($key = 'access_token', $default = null)
 {
     \Core\Cache::init_config_params();
     $this->enterprise_accesstoken = \Core\Cache::get('enterprise_accesstoken');
     if (empty($this->enterprise_accesstoken)) {
         $host = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s';
         $url = sprintf($host, $this->corpid, $this->corpsecret);
         $info = \Core\Curl::get($url);
         $respone = json_decode($info->response, true);
         if (isset($respone['access_token'])) {
             $this->enterprise_accesstoken = $respone;
         }
         \Core\Cache::set('enterprise_accesstoken', $respone);
     }
     if (!isset($this->accesstoken[$key])) {
         $this->accesstoken[$key] = $default;
     }
     return $this->accesstoken[$key];
 }
示例#7
0
 /**
  * 获取未关注用户
  * @param int $department_id
  * @param int $fetch_child
  */
 public function get_unfollow_members($department_id = 1, $fetch_child = 1)
 {
     $host = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=%s&department_id=%s&fetch_child=%s";
     $url = sprintf($host, $this->get_accesstoken(), $department_id, $fetch_child);
     $info = \Core\Curl::get($url);
     $respone = json_decode($info->response, true);
     if (isset($respone['userlist'])) {
         return $respone;
     }
     return FALSE;
 }