<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class wchats_mod extends module { function index(){ } public function access_token(){ $file_name = 'temp/001.txt'; if(file_exists($file_name) && ((time()-filemtime($file_name)) < 3600)){ $access_token = file_get_contents($file_name); }else{ $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".cfg('wchat_appid')."&secret=".cfg('wchat_appsecret'); $con = curl::get($url); $con = json_decode($con); $access_token = $con->access_token; file_put_contents($file_name,$access_token); } return $access_token; } public function user(){ $next_page = @$_GET['next']?$_GET['next']:""; if(!empty($next_page)){ $next = '&next_openid='.$next_page; }else{ $next = ''; } $url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$this->access_token().$next; $con = curl::get($url); $con = json_decode($con); $this->assign('data', $con->data->openid); $this->assign('next',$con->next_openid); $this->display(); } function api_get_user_info($openid){ $user_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=".$this->access_token()."&openid=".$openid."&lang=zh_CN"; $con = curl::get($user_url); $con = json_decode($con); return $con; } }