- 增加 微信小程序

- 增加 微信公众号
v6
Chaim 4 years ago
parent 8044a25484
commit adca5657c2

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -33,7 +34,7 @@ class Files
* @return bool * @return bool
* @throws DtAppException * @throws DtAppException
*/ */
public function delete(string $name) public function delete(string $name): bool
{ {
if (empty($name)) throw new DtAppException('请检查需要删除文件夹的名称'); if (empty($name)) throw new DtAppException('请检查需要删除文件夹的名称');
if (file_exists($name)) if (unlink($name)) return true; if (file_exists($name)) if (unlink($name)) return true;
@ -46,7 +47,7 @@ class Files
* @return bool * @return bool
* @throws DtAppException * @throws DtAppException
*/ */
public function deletes(string $name) public function deletes(string $name): bool
{ {
if (empty($name)) throw new DtAppException('请检查需要删除文件夹的名称'); if (empty($name)) throw new DtAppException('请检查需要删除文件夹的名称');
//先删除目录下的文件: //先删除目录下的文件:
@ -78,7 +79,7 @@ class Files
* @return bool * @return bool
* @throws DtAppException * @throws DtAppException
*/ */
public function folderZip(string $name, string $suffix_name = '.png', string $file_name = '*') public function folderZip(string $name, string $suffix_name = '.png', string $file_name = '*'): bool
{ {
if (empty($name)) throw new DtAppException('请检查需要打包的路径名称'); if (empty($name)) throw new DtAppException('请检查需要打包的路径名称');
try { try {
@ -103,7 +104,7 @@ class Files
* @param string $path * @param string $path
* @return array|string * @return array|string
*/ */
public function getFiles(string $path) public function getFiles(string $path): array
{ {
$files = []; $files = [];
if (is_dir($path)) { if (is_dir($path)) {
@ -131,7 +132,7 @@ class Files
* @param string $path * @param string $path
* @return bool * @return bool
*/ */
public function rmFiles(string $path) public function rmFiles(string $path): bool
{ {
$files = $this->getFiles($path); $files = $this->getFiles($path);
if (!is_array($files)) { if (!is_array($files)) {

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -29,7 +30,7 @@ class Ints
* @param int $num * @param int $num
* @return bool * @return bool
*/ */
public function isEvenNumbers(int $num) public function isEvenNumbers(int $num): bool
{ {
if ($num % 2 == 0) return true; if ($num % 2 == 0) return true;
return false; return false;
@ -40,7 +41,7 @@ class Ints
* @param int $num * @param int $num
* @return bool * @return bool
*/ */
public function isOddNumbers(int $num) public function isOddNumbers(int $num): bool
{ {
if ($num % 2 == 0) return false; if ($num % 2 == 0) return false;
return true; return true;

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -30,7 +31,7 @@ class Pregs
* @param $mobile * @param $mobile
* @return bool * @return bool
*/ */
public function isIphone($mobile) public function isIphone($mobile): bool
{ {
if (preg_match('/^[1]([3-9])[0-9]{9}$/', $mobile)) return true; if (preg_match('/^[1]([3-9])[0-9]{9}$/', $mobile)) return true;
return false; return false;
@ -42,7 +43,7 @@ class Pregs
* @param $mobile * @param $mobile
* @return bool * @return bool
*/ */
public function isIphoneAll($mobile) public function isIphoneAll($mobile): bool
{ {
if (preg_match('/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/', $mobile)) return true; if (preg_match('/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/', $mobile)) return true;
return false; return false;
@ -54,7 +55,7 @@ class Pregs
* @param $tel * @param $tel
* @return bool * @return bool
*/ */
public function isTel($tel) public function isTel($tel): bool
{ {
if (preg_match("/^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/", $tel)) return true; if (preg_match("/^(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}$/", $tel)) return true;
return false; return false;
@ -66,7 +67,7 @@ class Pregs
* @param int $id 身份证号码 * @param int $id 身份证号码
* @return bool * @return bool
*/ */
public function isIdCard($id) public function isIdCard($id): bool
{ {
if (preg_match("/^\d{15}|\d{18}$/", $id)) return true; if (preg_match("/^\d{15}|\d{18}$/", $id)) return true;
return false; return false;
@ -78,7 +79,7 @@ class Pregs
* @param $digit * @param $digit
* @return bool * @return bool
*/ */
public function isDigit($digit) public function isDigit($digit): bool
{ {
if (preg_match("/^\d*$/", $digit)) return true; if (preg_match("/^\d*$/", $digit)) return true;
return false; return false;
@ -90,7 +91,7 @@ class Pregs
* @param $num * @param $num
* @return bool * @return bool
*/ */
public function isNum($num) public function isNum($num): bool
{ {
if (is_numeric($num)) return true; if (is_numeric($num)) return true;
return false; return false;
@ -102,7 +103,7 @@ class Pregs
* @param $str * @param $str
* @return bool * @return bool
*/ */
public function isStr($str) public function isStr($str): bool
{ {
if (preg_match("/^\w+$/", $str)) return true; if (preg_match("/^\w+$/", $str)) return true;
return false; return false;
@ -114,7 +115,7 @@ class Pregs
* @param $str * @param $str
* @return bool * @return bool
*/ */
public function isPassword($str) public function isPassword($str): bool
{ {
if (preg_match("/^[a-zA-Z]\w{5,17}$/", $str)) return true; if (preg_match("/^[a-zA-Z]\w{5,17}$/", $str)) return true;
return false; return false;
@ -126,7 +127,7 @@ class Pregs
* @param $str * @param $str
* @return bool * @return bool
*/ */
public function isChinese($str) public function isChinese($str): bool
{ {
if (preg_match("/^[\u4e00-\u9fa5],{0,}$/", $str)) return true; if (preg_match("/^[\u4e00-\u9fa5],{0,}$/", $str)) return true;
return false; return false;
@ -138,7 +139,7 @@ class Pregs
* @param $email * @param $email
* @return bool * @return bool
*/ */
public function isEmail($email) public function isEmail($email): bool
{ {
if (preg_match("/^\w+[-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $email)) return true; if (preg_match("/^\w+[-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/", $email)) return true;
return false; return false;
@ -150,7 +151,7 @@ class Pregs
* @param $url * @param $url
* @return bool * @return bool
*/ */
public function isLink($url) public function isLink($url): bool
{ {
if (preg_match("/http:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is", $url)) return true; if (preg_match("/http:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is", $url)) return true;
return false; return false;
@ -162,7 +163,7 @@ class Pregs
* @param $qq * @param $qq
* @return bool * @return bool
*/ */
public function isQq($qq) public function isQq($qq): bool
{ {
if (preg_match("/^[1-9][0-9]{4,}$/", $qq)) return true; if (preg_match("/^[1-9][0-9]{4,}$/", $qq)) return true;
return false; return false;
@ -174,7 +175,7 @@ class Pregs
* @param $ip * @param $ip
* @return bool * @return bool
*/ */
public function isIp($ip) public function isIp($ip): bool
{ {
if (preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) return true; if (preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/", $ip)) return true;
return false; return false;

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -27,11 +28,11 @@ class Requests
* 判断输入的参数 * 判断输入的参数
* @param array $data * @param array $data
* @param array $arr * @param array $arr
* @return array|bool * @return array
*/ */
public function isEmpty(array $data, array $arr) public function isEmpty(array $data, array $arr): array
{ {
foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) return false; foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) return '';
return $data; return $data;
} }
@ -41,7 +42,7 @@ class Requests
* @param array $arr * @param array $arr
* @return array * @return array
*/ */
public function isEmptyRet(array $data, array $arr) public function isEmptyRet(array $data, array $arr): array
{ {
foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) \DtApp\ThinkLibrary\facade\Returns::jsonError('请检查参数', 102); foreach ($arr as $k => $v) if (empty(isset($data["$v"]) ? $data["$v"] : '')) \DtApp\ThinkLibrary\facade\Returns::jsonError('请检查参数', 102);
return $data; return $data;
@ -51,7 +52,7 @@ class Requests
* 判断是否为GET方式 * 判断是否为GET方式
* @return bool * @return bool
*/ */
public function isGet() public function isGet(): bool
{ {
return request()->isGet(); return request()->isGet();
} }
@ -60,7 +61,7 @@ class Requests
* 判断是否为POST方式 * 判断是否为POST方式
* @return bool * @return bool
*/ */
public function isPost() public function isPost(): bool
{ {
return request()->isPost(); return request()->isPost();
} }
@ -69,7 +70,7 @@ class Requests
* 判断是否为PUT方式 * 判断是否为PUT方式
* @return boolean * @return boolean
*/ */
public function isPut() public function isPut(): bool
{ {
return request()->isPut(); return request()->isPut();
} }
@ -78,7 +79,7 @@ class Requests
* 判断是否为DELETE方式 * 判断是否为DELETE方式
* @return boolean * @return boolean
*/ */
public function isDelete() public function isDelete(): bool
{ {
return request()->isDelete(); return request()->isDelete();
} }
@ -87,7 +88,7 @@ class Requests
* 判断是否为Ajax方式 * 判断是否为Ajax方式
* @return bool * @return bool
*/ */
public function isAjax() public function isAjax(): bool
{ {
return request()->isAjax(); return request()->isAjax();
} }
@ -96,7 +97,7 @@ class Requests
* 获取域名地址 * 获取域名地址
* @return string * @return string
*/ */
public function getWebsiteAddress() public function getWebsiteAddress(): string
{ {
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
return $http_type . $_SERVER['HTTP_HOST'] . "/"; return $http_type . $_SERVER['HTTP_HOST'] . "/";

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -31,7 +32,7 @@ class UnIqIds
* @param string $prefix 编码前缀 * @param string $prefix 编码前缀
* @return string * @return string
*/ */
public function random($size = 10, $type = 1, $prefix = '') public function random($size = 10, $type = 1, $prefix = ''): string
{ {
$numbs = '0123456789'; $numbs = '0123456789';
$chars = 'abcdefghijklmnopqrstuvwxyz'; $chars = 'abcdefghijklmnopqrstuvwxyz';
@ -51,7 +52,7 @@ class UnIqIds
* @param string $prefix * @param string $prefix
* @return string * @return string
*/ */
public function date($size = 16, $prefix = '') public function date($size = 16, $prefix = ''): string
{ {
if ($size < 14) $size = 14; if ($size < 14) $size = 14;
$string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s'); $string = $prefix . date('Ymd') . (date('H') + date('i')) . date('s');
@ -65,11 +66,11 @@ class UnIqIds
* @param string $prefix * @param string $prefix
* @return string * @return string
*/ */
public function number($size = 12, $prefix = '') public function number($size = 12, $prefix = ''): string
{ {
$time = time() . ''; $time = time() . '';
if ($size < 10) $size = 10; if ($size < 10) $size = 10;
$string = $prefix . ($time[0] + $time[1]) . substr($time, 2) . rand(0, 9); $string = $prefix . ($time[0] . $time[1]) . substr($time, 2) . rand(0, 9);
while (strlen($string) < $size) $string .= rand(0, 9); while (strlen($string) < $size) $string .= rand(0, 9);
return $string; return $string;
} }

@ -13,6 +13,7 @@
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary // | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
declare (strict_types=1);
namespace DtApp\ThinkLibrary\helper; namespace DtApp\ThinkLibrary\helper;
@ -29,9 +30,9 @@ class Urls
* @param string $url * @param string $url
* @return string * @return string
*/ */
public function lenCode(string $url) public function lenCode(string $url): string
{ {
if (empty($url)) return false; if (empty($url)) return '';
return urlencode($url); return urlencode($url);
} }
@ -40,9 +41,9 @@ class Urls
* @param string $url * @param string $url
* @return string * @return string
*/ */
public function deCode(string $url) public function deCode(string $url): string
{ {
if (empty($url)) return false; if (empty($url)) return '';
return urldecode($url); return urldecode($url);
} }
@ -51,7 +52,7 @@ class Urls
* @param array $data * @param array $data
* @return string * @return string
*/ */
public function toParams(array $data) public function toParams(array $data): string
{ {
$buff = ""; $buff = "";
foreach ($data as $k => $v) if ($k != "sign" && $v !== "" && !is_array($v)) $buff .= $k . "=" . $v . "&"; foreach ($data as $k => $v) if ($k != "sign" && $v !== "" && !is_array($v)) $buff .= $k . "=" . $v . "&";

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\WeChat;
use DtApp\Curl\CurlException;
use DtApp\Curl\Get;
use DtApp\ThinkLibrary\Service;
/**
* 微信公众号 - 消息管理
* Class MessageManagementService
* @package DtApp\ThinkLibrary\service\WeChat
*/
class MessageManagementService extends Service
{
/**
* 设置所属行业
* https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#0
* @param string $access_token
* @param array $data
* @return bool|mixed|string
* @throws CurlException
*/
public function setIndustry(string $access_token, array $data = [])
{
$url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token={$access_token}";
$curl = new Get();
if (is_array($data)) $data = json_encode($data);
return $curl->http($url, $data, true);
}
}

@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\WeMini;
use DtApp\Curl\CurlException;
use DtApp\Curl\Get;
use DtApp\ThinkLibrary\Service;
/**
* 微信小程序 - 接口调用凭据
* Class AccessTokenService
* @package DtApp\ThinkLibrary\service\WeMini
*/
class AccessTokenService extends Service
{
/**
* 获取小程序全局唯一后台接口调用凭据access_token
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
* @param string $appid
* @param string $secret
* @param string $grant_type
* @return bool|mixed|string
* @throws CurlException
*/
public function code2Session(string $appid, string $secret, string $grant_type = 'client_credential')
{
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type={$grant_type}&appid={$appid}&secret={$secret}";
$curl = new Get();
return $curl->http($url, '', true);
}
}

@ -14,19 +14,16 @@
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library // | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service; namespace DtApp\ThinkLibrary\service\WeMini;
use DtApp\ThinkLibrary\Service; use DtApp\ThinkLibrary\Service;
/** /**
* 测试服务 * 微信小程序 - 客服消息
* Class TestService * Class CustomerMessageService
* @package DtApp\ThinkLibrary\service * @package DtApp\ThinkLibrary\service\WeMini
*/ */
class TestService extends Service class CustomerMessageService extends Service
{ {
public function index()
{
return 'service.test.index';
}
} }

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\WeMini;
use DtApp\Curl\CurlException;
use DtApp\Curl\Get;
use DtApp\ThinkLibrary\Service;
/**
* 微信小程序 - 登录
* Class LoginService
* @package DtApp\ThinkLibrary\service\WeMini
*/
class LoginService extends Service
{
/**
* 登录凭证校验
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html
* @param string $appid
* @param string $secret
* @param string $js_code
* @param string $grant_type
* @return bool|mixed|string
* @throws CurlException
*/
public function code2Session(string $appid, string $secret, string $js_code, string $grant_type = 'authorization_code')
{
$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$secret}&js_code={$js_code}&grant_type={$grant_type}";
$curl = new Get();
return $curl->http($url, '', true);
}
}

@ -38,10 +38,10 @@ class NewTmplService extends Service
*/ */
public function addTemplate(string $access_token, array $data = []) public function addTemplate(string $access_token, array $data = [])
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
if (is_array($data)) $data = json_encode($data); if (is_array($data)) $data = json_encode($data);
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), $data, true); return $curl->http($url, $data, true);
} }
/** /**
@ -54,13 +54,13 @@ class NewTmplService extends Service
*/ */
public function deleteTemplate(string $access_token, string $priTmplId) public function deleteTemplate(string $access_token, string $priTmplId)
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
$data = [ $data = [
'priTmplId' => $priTmplId 'priTmplId' => $priTmplId
]; ];
if (is_array($data)) $data = json_encode($data); if (is_array($data)) $data = json_encode($data);
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), $data, true); return $curl->http($url, $data, true);
} }
/** /**
@ -72,9 +72,9 @@ class NewTmplService extends Service
*/ */
public function getCategory(string $access_token) public function getCategory(string $access_token)
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/getcategory?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), '', true); return $curl->http($url, '', true);
} }
/** /**
@ -87,13 +87,13 @@ class NewTmplService extends Service
*/ */
public function getPubTemplateKeyWordsById(string $access_token, string $tid) public function getPubTemplateKeyWordsById(string $access_token, string $tid)
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
$data = [ $data = [
'tid' => $tid 'tid' => $tid
]; ];
if (is_array($data)) $data = json_encode($data); if (is_array($data)) $data = json_encode($data);
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), $data, true); return $curl->http($url, $data, true);
} }
/** /**
@ -106,10 +106,10 @@ class NewTmplService extends Service
*/ */
public function getPubTemplateTitleList(string $access_token, array $data = []) public function getPubTemplateTitleList(string $access_token, array $data = [])
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
if (is_array($data)) $data = json_encode($data); if (is_array($data)) $data = json_encode($data);
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), $data, true); return $curl->http($url, $data, true);
} }
/** /**
@ -121,9 +121,9 @@ class NewTmplService extends Service
*/ */
public function getTemplateList(string $access_token) public function getTemplateList(string $access_token)
{ {
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token={$access_token}";
$curl = new Get(); $curl = new Get();
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), '', true); return $curl->http($url, '', true);
} }
/** /**
@ -136,9 +136,9 @@ class NewTmplService extends Service
*/ */
public function send(string $access_token, array $data = []) public function send(string $access_token, array $data = [])
{ {
$url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN"; $url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={$access_token}";
$curl = new Post(); $curl = new Post();
return $curl->http(str_replace('ACCESS_TOKEN', $access_token, $url), $data, true); return $curl->http($url, $data, true);
} }
} }

@ -0,0 +1,74 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\WeMini;
use DtApp\Curl\CurlException;
use DtApp\Curl\Post;
use DtApp\ThinkLibrary\Service;
/**
* 微信小程序 - 小程序码
* Class QrCodeService
* @package DtApp\ThinkLibrary\service\WeMini
*/
class QrCodeService extends Service
{
/**
* 获取小程序二维码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.createQRCode.html
* @param string $access_token 接口调用凭证
* @param array $data
* @return array|bool|mixed|string
* @throws CurlException
*/
public function createWxaQrCode(string $access_token, array $data = [])
{
$url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token={$access_token}";
$curl = new Post();
return $curl->http($url, $data);
}
/**
* 获取小程序码,适用于需要的码数量较少的业务场景。通过该接口生成的小程序码,永久有效,有数量限制
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.get.html
* @param string $access_token
* @param array $data
* @return array|bool|mixed|string
* @throws CurlException
*/
public function getWxaCode(string $access_token, array $data = [])
{
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$access_token}";
$curl = new Post();
return $curl->http($url, $data);
}
/**
* 获取小程序码,适用于需要的码数量极多的业务场景。通过该接口生成的小程序码,永久有效,数量暂无限制
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/qr-code/wxacode.getUnlimited.html
* @param string $access_token
* @param array $data
* @return array|bool|mixed|string
* @throws CurlException
*/
public function getWxaCodeUnLimit(string $access_token, array $data = [])
{
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$access_token}";
$curl = new Post();
return $curl->http($url, $data);
}
}

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\WeMini;
use DtApp\Curl\CurlException;
use DtApp\Curl\Get;
use DtApp\ThinkLibrary\Service;
/**
* 微信小程序 - 用户信息
* Class UserInfoService
* @package DtApp\ThinkLibrary\service\WeMini
*/
class UserInfoService extends Service
{
/**
* 用户支付完成后,获取该用户的 UnionId无需用户授权
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.getPaidUnionId.html
* @param string $access_token
* @param string $openid
* @return bool|mixed|string
* @throws CurlException
*/
public function getPaidUnionId(string $access_token, string $openid)
{
$url = "https://api.weixin.qq.com/wxa/getpaidunionid?access_token={$access_token}&openid={$openid}";
$curl = new Get();
return $curl->http($url, '', true);
}
}

@ -0,0 +1,29 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\ip;
use DtApp\ThinkLibrary\Service;
/**
* IP-纯真数据库
* Class QqWryService
* @package DtApp\ThinkLibrary\service\ip
*/
class QqWryService extends Service
{
}
Loading…
Cancel
Save