mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-05 19:41:44 +08:00
[更新]增加We快速加载器
This commit is contained in:
parent
c3206134c3
commit
2423687698
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
/.idea
|
||||
/.git
|
||||
/.idea
|
||||
/.DS_Store
|
||||
/vendor
|
||||
/Cache
|
||||
/Test/cert
|
||||
/composer.lock
|
||||
|
@ -8,7 +8,11 @@ $config = [
|
||||
'appsecret' => '78b7b8d65bd67b078babf951d4342b42',
|
||||
];
|
||||
|
||||
$mini = new WeMini\Qrcode($config);
|
||||
//We::config($config);
|
||||
|
||||
$mini = We::WeMiniQrcode($config);
|
||||
|
||||
//$mini = new WeMini\Qrcode($config);
|
||||
|
||||
//echo '<pre>';
|
||||
try {
|
||||
|
107
We.php
Normal file
107
We.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
use WeChat\Contracts\DataArray;
|
||||
use WeChat\Exceptions\InvalidInstanceException;
|
||||
|
||||
/**
|
||||
* 加载缓存器
|
||||
*
|
||||
* Class We
|
||||
* @library WeChatDeveloper
|
||||
* @author Anyon<zoujingli@qq.com>
|
||||
* @date 2018/05/24 13:23
|
||||
*
|
||||
* ----- WeChat -----
|
||||
* @method \WeChat\Card WeChatCard($options = []) static 微信卡券管理
|
||||
* @method \WeChat\Custom WeChatCustom($options = []) static 微信客服消息
|
||||
* @method \WeChat\Limit WeChatLimit($options = []) static 接口调用频次限制
|
||||
* @method \WeChat\Media WeChatMedia($options = []) static 微信素材管理
|
||||
* @method \WeChat\Menu WeChatMenu($options = []) static 微信菜单管理
|
||||
* @method \WeChat\Oauth WeChatOauth($options = []) static 微信网页授权
|
||||
* @method \WeChat\Pay WeChatPay($options = []) static 微信支付商户
|
||||
* @method \WeChat\Product WeChatProduct($options = []) static 微信商店管理
|
||||
* @method \WeChat\Qrcode WeChatQrcode($options = []) static 微信二维码管理
|
||||
* @method \WeChat\Receive WeChatReceive($options = []) static 微信推送管理
|
||||
* @method \WeChat\Scan WeChatScan($options = []) static 微信扫一扫接入管理
|
||||
* @method \WeChat\Script WeChatScript($options = []) static 微信前端支持
|
||||
* @method \WeChat\Shake WeChatShake($options = []) static 微信揺一揺周边
|
||||
* @method \WeChat\Tags WeChatTags($options = []) static 微信用户标签管理
|
||||
* @method \WeChat\Template WeChatTemplate($options = []) static 微信模板消息
|
||||
* @method \WeChat\User WeChatUser($options = []) static 微信粉丝管理
|
||||
* @method \WeChat\Wifi WeChatWifi($options = []) static 微信门店WIFI管理
|
||||
*
|
||||
* ----- WeMini -----
|
||||
* @method \WeMini\Crypt WeMiniCrypt($options = []) static 小程序数据加密处理
|
||||
* @method \WeMini\Plugs WeMiniPlugs($options = []) static 小程序插件管理
|
||||
* @method \WeMini\Poi WeMiniPoi($options = []) static 小程序地址管理
|
||||
* @method \WeMini\Qrcode WeMiniQrcode($options = []) static 小程序二维码管理
|
||||
* @method \WeMini\Template WeMiniTemplate($options = []) static 小程序模板消息支持
|
||||
* @method \WeMini\Total WeMiniTotal($options = []) static 小程序数据接口
|
||||
*
|
||||
* ----- WePay -----
|
||||
* @method \WePay\Bill WePayBill($options = []) static 微信商户账单及评论
|
||||
* @method \WePay\Order WePayOrder($options = []) static 微信商户订单
|
||||
* @method \WePay\Refund WePayRefund($options = []) static 微信商户退款
|
||||
* @method \WePay\Transfers WePayTransfers($options = []) static 微信商户打款到零钱
|
||||
* @method \WePay\TransFresBank WePayTransFresBank($options = []) static 微信商户打款到银行卡
|
||||
*/
|
||||
class We
|
||||
{
|
||||
/**
|
||||
* 静态配置
|
||||
* @var array
|
||||
*/
|
||||
private static $config;
|
||||
|
||||
/**
|
||||
* 设置及获取参数
|
||||
* @param array $option
|
||||
* @return array
|
||||
*/
|
||||
public static function config($option = null)
|
||||
{
|
||||
if (is_array($option)) {
|
||||
self::$config = new DataArray($option);
|
||||
}
|
||||
if (self::$config instanceof DataArray) {
|
||||
return self::$config->get();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $arguments
|
||||
* @return mixed
|
||||
* @throws InvalidInstanceException
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
if (substr($name, 0, 6) === 'WeChat') {
|
||||
$class = 'WeChat\\' . substr($name, 6);
|
||||
} elseif (substr($name, 0, 6) === 'WeMini') {
|
||||
$class = 'WeMini\\' . substr($name, 6);
|
||||
} elseif (substr($name, 0, 5) === 'WePay') {
|
||||
$class = 'WePay\\' . substr($name, 5);
|
||||
}
|
||||
if (!empty($class) && class_exists($class)) {
|
||||
$option = array_pop($arguments);
|
||||
$config = is_array($option) ? $option : self::$config->get();
|
||||
return new $class($config);
|
||||
}
|
||||
throw new InvalidInstanceException("class {$name} not found");
|
||||
}
|
||||
|
||||
}
|
40
WeChat/Exceptions/InvalidInstanceException.php
Normal file
40
WeChat/Exceptions/InvalidInstanceException.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: http://think.ctolog.com
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// +----------------------------------------------------------------------
|
||||
// | github开源项目:https://github.com/zoujingli/WeChatDeveloper
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace WeChat\Exceptions;
|
||||
|
||||
/**
|
||||
* 加载类异常
|
||||
* Class InvalidInstanceException
|
||||
* @package WeChat\Exceptions
|
||||
*/
|
||||
class InvalidInstanceException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $raw = [];
|
||||
|
||||
/**
|
||||
* InvalidResponseException constructor.
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param array $raw
|
||||
*/
|
||||
public function __construct($message, $code = 0, $raw = [])
|
||||
{
|
||||
parent::__construct($message, intval($code));
|
||||
$this->raw = $raw;
|
||||
}
|
||||
}
|
@ -41,6 +41,7 @@ class Oauth extends BasicWeChat
|
||||
/**
|
||||
* 通过 code 获取 AccessToken 和 openid
|
||||
* @return bool|array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getOauthAccessToken()
|
||||
{
|
||||
@ -55,6 +56,7 @@ class Oauth extends BasicWeChat
|
||||
* 刷新AccessToken并续期
|
||||
* @param string $refresh_token
|
||||
* @return bool|array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getOauthRefreshToken($refresh_token)
|
||||
{
|
||||
@ -68,6 +70,7 @@ class Oauth extends BasicWeChat
|
||||
* @param string $access_token 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
|
||||
* @param string $openid 用户的唯一标识
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function checkOauthAccessToken($access_token, $openid)
|
||||
{
|
||||
@ -81,6 +84,7 @@ class Oauth extends BasicWeChat
|
||||
* @param string $openid 用户的唯一标识
|
||||
* @param string $lang 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
|
||||
* @return array
|
||||
* @throws Exceptions\InvalidResponseException
|
||||
*/
|
||||
public function getUserInfo($access_token, $openid, $lang = 'zh_CN')
|
||||
{
|
||||
|
@ -15,7 +15,6 @@
|
||||
namespace WeChat;
|
||||
|
||||
use WeChat\Contracts\BasicPay;
|
||||
use WeChat\Contracts\DataArray;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WePay\Bill;
|
||||
use WePay\Order;
|
||||
@ -31,18 +30,6 @@ use WePay\TransFresBank;
|
||||
class Pay extends BasicPay
|
||||
{
|
||||
|
||||
/**
|
||||
* 商户配置
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* 当前请求数据
|
||||
* @var DataArray
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* 统一下单
|
||||
* @param array $options
|
||||
|
@ -24,6 +24,9 @@
|
||||
"ext-openssl": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"We.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"WePay\\": "WePay",
|
||||
"WeChat\\": "WeChat",
|
||||
|
@ -25,5 +25,8 @@ spl_autoload_register(function ($classname) {
|
||||
if (stripos($classname, 'WePay') === 0) {
|
||||
include $filename;
|
||||
}
|
||||
if ($classname === 'We') {
|
||||
include $filename;
|
||||
}
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user