ThinkAdmin/extend/controller/BasicWechat.php
2018-05-03 16:05:14 +08:00

60 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://think.ctolog.com
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | github开源项目https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------
namespace controller;
use service\WechatService;
use think\Controller;
/**
* 微信基础控制器
* Class BasicWechat
* @package controller
*/
class BasicWechat extends Controller
{
/**
* 当前粉丝用户OPENID
* @var string
*/
protected $openid;
/**
* 获取粉丝用户OPENID
* @return bool|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
protected function getOpenid()
{
$url = $this->request->url(true);
return WechatService::webOauth($url, 0)['openid'];
}
/**
* 获取微信粉丝信息
* @return bool|array
* @throws \Exception
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
protected function getFansinfo()
{
$url = $this->request->url(true);
return WechatService::webOauth($url, 1)['fansinfo'];
}
}