1、添加应用菜单。

2、access_token

/**
* 获取token
* @return [type] [description]
*/
public function getToken()
{
$file = "token.txt";
{
$token = file_get_contents($file);
$token = json_decode($token,true);
if(!$token['access_token'] || time()-$token['expires_in'] > 7000)
{
$url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=".$this->corpid."&corpsecret=".strtoupper($this->secrect);
$token = $this->GetHttp($url);
$token = json_decode($token,true);
$token['expires_in'] = time();
file_put_contents("token.txt",json_encode($token));
return $token['access_token'];
}
else
{
$url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=".$this->corpid."&corpsecret=".strtoupper($this->secrect);
$token = $this->GetHttp($url);
$token = json_decode($token,true);
$token['expires_in'] = time();
file_put_contents("token.txt",json_encode($token));
return $token['access_token'];
}
}

}

3、通过code获取user_ticket。

/**
* 获取code,getToken()返回token,获取user_ticket。
*/
function Code(){
$url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=".$this->gettoken()."&code=".$_GET['code'];
$data = $this->GetHttp($url);
$ticket = json_decode($data,true);
$arr = $this->UserTicket($ticket['user_ticket']);
echo "<pre>";
print_r($arr);
}

4、通过user_ticket获取用户信息。

/**
* user_ticket获取成员详情
*/
function UserTicket($user_ticket = ''){
$url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserdetail?access_token=".$this->getToken();
$data = array(
'user_ticket' => $user_ticket
);
$arr = $this->Curl($url,json_encode($data));
return json_decode($arr,true);
}

最新文章

  1. 阻止默认事件event.preventDefault();
  2. Fedora 23安装配置mysql数据库,修改初始密码及登陆
  3. Web开发流程
  4. mysql本地可以访问 网络不能访问
  5. Knockout.Js案例一Introduction
  6. PHP-Beast V0.6 发布 (PHP源码加密模块)
  7. 使用Python中的urlparse、urllib抓取和解析网页(一)(转)
  8. 3、SQL基础整理(分组)
  9. Python 判断一个字符串是否在列表中任何一个字符串中出现过
  10. 使用Java Service Wrapper在Linux下配置Tomcat应用
  11. 【BZOJ】【1087】【SCOI2005】互不侵犯King
  12. CCF 201403-2 窗口 (STL模拟)
  13. DevExpress z
  14. 宁波Uber优步司机奖励政策(2月1日~2月7日)
  15. winform Label与DataGridView右对齐 分类: WinForm 2014-05-19 20:51 446人阅读 评论(0) 收藏
  16. Excel操作 Microsoft.Office.Interop.Excel.dll的使用
  17. bzoj 1066 : [SCOI2007]蜥蜴 网络流
  18. 如何在windows的DOS窗口中正常显示中文(UTF-8字符)
  19. socket-详细分析No buffer space available(转)
  20. sql 生成开始日期到结束日期与开始日期的相差天数

热门文章

  1. 利用curl 模拟多线程
  2. Git忽略规则和.gitignore规则不生效的解决办法
  3. 关于JAVA架构师
  4. Netty简单的HTTP服务器
  5. 信息安全-加密:DES 加密
  6. 科学-建筑学-事务所:KPF
  7. etcd 命令行(转)
  8. jvm感知docker容器参数
  9. Java常用的线程池
  10. window.open打开新窗口报错ie 位指明错误,原因是window没有加引号!