application/common.php

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Db;
// 应用公共文件
//通过https 中的get 或 post
function https_request($url, $data = null)
{
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
	if (!empty($data)){
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
	}
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	$output = curl_exec($curl);
	curl_close($curl);
	return $output;

}


define('TOKENS', "tuiguangaaaxxx1");

/*
*   微信 普通的access token
*   已优化了有效时间
*   7200秒以内,不重复获取以免造成资源浪费
*/
function access_token(){
    
    $pttoken = Db::name('accesstoken')->where('tokenname','ptaccess')->find();

    $appid = "xxxxxxxxxxxxxxxx";
    $secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";

        //获取普通的accesstoken,因为获取用户信息需要普通token.
        if($pttoken)
        {
            date_default_timezone_set('PRC');//定义时区
            if($pttoken['expires'] < time()-7200)
            {
                   // echo "超时了,重新获取";
                    Db::name('accesstoken')->where('tokenname','ptaccess')->delete(); //删除之前存入的token数据
                    /*普通的access,给获取关注状态没有openID等信息*/
                    $acc = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
                    $result1 =  file_get_contents($acc);
                    $jsondecode1 = json_decode($result1); //对JSON格式的字符串进行编码
                    $array1 = get_object_vars($jsondecode1);//转换成数组

                    //普通token存到数据库以及现在时间戳
后面还有 34 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。