Files
liche/api/controllers/Weixin.php
T
2021-07-29 14:49:16 +08:00

87 lines
2.3 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2020/9/14
* Time: 10:51
*/
class Weixin extends CI_Controller{
private $app_id;
private $reset;
private $appid;
private $secret;
private $corpid;
private $corpsecret;
public function __construct(){
parent::__construct();
$this->app_id = $this->input->get('app_id');
$this->reset = $this->input->get('reset');
$this->appid = $this->input->get('appid');
$this->secret = $this->input->get('secret');
$this->corpid = $this->input->get('corpid');
$this->corpsecret = $this->input->get('corpsecret');
$wx_configs = array(
//小鱼冒泡
"13.1" => array('appid' => "wx13bb4ff11493bc7c", "secret" => "40d6032dece9aba7f9c2faa482abd827"),
);
$wx_config = $wx_configs[$this->app_id];
if($wx_config){
!$this->appid && $this->appid = $wx_config['appid'];
!$this->secret && $this->secret = $wx_config['secret'];
}
$param = array('appid' => $this->appid, "secret" => $this->secret);
$this->load->library("hd_wechat", $param);
}
/**
* 获取access_token
*/
function access_token(){
$access_token = $this->hd_wechat->access_token($this->reset);
$data = array("access_token" => $access_token);
echo json_encode($data, JSON_UNESCAPED_UNICODE);
return;
}
/**
* 获取分享凭证
*/
function api_ticket(){
$api_ticket = $this->hd_wechat->api_ticket($this->reset);
$data = array("api_ticket" => $api_ticket);
echo json_encode($data, JSON_UNESCAPED_UNICODE);
return;
}
/*
* 企业微信access_token
*/
public function qy_access_token(){
$app = $this->input->get('app');
$corpid = $this->input->get('corpid');
$corpsecret = $this->input->get('corpsecret');
$params = array();
$app && $params['app'] = $app;
$corpid && $params['corpid'] = $corpid;
$corpsecret && $params['corpsecret'] = $corpsecret;
$this->load->library('wx_qyapi', $params);
$access_token = $this->wx_qyapi->access_token();
$data['access_token'] = $access_token;
echo json_encode($data, JSON_UNESCAPED_UNICODE);
return;
}
}