init
This commit is contained in:
79
vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php
vendored
Normal file
79
vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/Client.php
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\ActivityMessage;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function createActivityId()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/message/wxopen/activityid/create');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateMessage(string $activityId, int $state = 0, array $params = [])
|
||||
{
|
||||
if (!in_array($state, [0, 1], true)) {
|
||||
throw new InvalidArgumentException('"state" should be "0" or "1".');
|
||||
}
|
||||
|
||||
$params = $this->formatParameters($params);
|
||||
|
||||
$params = [
|
||||
'activity_id' => $activityId,
|
||||
'target_state' => $state,
|
||||
'template_info' => ['parameter_list' => $params],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/wxopen/updatablemsg/send', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatParameters(array $params)
|
||||
{
|
||||
$formatted = [];
|
||||
|
||||
foreach ($params as $name => $value) {
|
||||
if (!in_array($name, ['member_count', 'room_limit', 'path', 'version_type'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('version_type' === $name && !in_array($value, ['develop', 'trial', 'release'], true)) {
|
||||
throw new InvalidArgumentException('Invalid value of attribute "version_type".');
|
||||
}
|
||||
|
||||
$formatted[] = [
|
||||
'name' => $name,
|
||||
'value' => strval($value),
|
||||
];
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/ActivityMessage/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\ActivityMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['activity_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
80
vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php
vendored
Normal file
80
vendor/overtrue/wechat/src/MiniProgram/AppCode/Client.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\AppCode;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Http\StreamResponse;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get AppCode.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*/
|
||||
public function get(string $path, array $optional = [])
|
||||
{
|
||||
$params = array_merge([
|
||||
'path' => $path,
|
||||
], $optional);
|
||||
|
||||
return $this->getStream('wxa/getwxacode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get AppCode unlimit.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*/
|
||||
public function getUnlimit(string $scene, array $optional = [])
|
||||
{
|
||||
$params = array_merge([
|
||||
'scene' => $scene,
|
||||
], $optional);
|
||||
|
||||
return $this->getStream('wxa/getwxacodeunlimit', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create QrCode.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*/
|
||||
public function getQrCode(string $path, int $width = null)
|
||||
{
|
||||
return $this->getStream('cgi-bin/wxaapp/createwxaqrcode', compact('path', 'width'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stream.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
protected function getStream(string $endpoint, array $params)
|
||||
{
|
||||
$response = $this->requestRaw($endpoint, 'POST', ['json' => $params]);
|
||||
|
||||
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
|
||||
return StreamResponse::buildFromPsrResponse($response);
|
||||
}
|
||||
|
||||
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/AppCode/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\AppCode;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['app_code'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
91
vendor/overtrue/wechat/src/MiniProgram/Application.php
vendored
Normal file
91
vendor/overtrue/wechat/src/MiniProgram/Application.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram;
|
||||
|
||||
use EasyWeChat\BasicService;
|
||||
use EasyWeChat\Kernel\ServiceContainer;
|
||||
|
||||
/**
|
||||
* Class Application.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*
|
||||
* @property \EasyWeChat\MiniProgram\Auth\AccessToken $access_token
|
||||
* @property \EasyWeChat\MiniProgram\DataCube\Client $data_cube
|
||||
* @property \EasyWeChat\MiniProgram\AppCode\Client $app_code
|
||||
* @property \EasyWeChat\MiniProgram\Auth\Client $auth
|
||||
* @property \EasyWeChat\OfficialAccount\Server\Guard $server
|
||||
* @property \EasyWeChat\MiniProgram\Encryptor $encryptor
|
||||
* @property \EasyWeChat\MiniProgram\TemplateMessage\Client $template_message
|
||||
* @property \EasyWeChat\OfficialAccount\CustomerService\Client $customer_service
|
||||
* @property \EasyWeChat\MiniProgram\Plugin\Client $plugin
|
||||
* @property \EasyWeChat\MiniProgram\Plugin\DevClient $plugin_dev
|
||||
* @property \EasyWeChat\MiniProgram\UniformMessage\Client $uniform_message
|
||||
* @property \EasyWeChat\MiniProgram\ActivityMessage\Client $activity_message
|
||||
* @property \EasyWeChat\MiniProgram\Express\Client $logistics
|
||||
* @property \EasyWeChat\MiniProgram\NearbyPoi\Client $nearby_poi
|
||||
* @property \EasyWeChat\MiniProgram\OCR\Client $ocr
|
||||
* @property \EasyWeChat\MiniProgram\Soter\Client $soter
|
||||
* @property \EasyWeChat\BasicService\Media\Client $media
|
||||
* @property \EasyWeChat\BasicService\ContentSecurity\Client $content_security
|
||||
* @property \EasyWeChat\MiniProgram\Mall\ForwardsMall $mall
|
||||
* @property \EasyWeChat\MiniProgram\SubscribeMessage\Client $subscribe_message
|
||||
* @property \EasyWeChat\MiniProgram\RealtimeLog\Client $realtime_log
|
||||
* @property \EasyWeChat\MiniProgram\Search\Client $search
|
||||
* @property \EasyWeChat\MiniProgram\Live\Client $live
|
||||
* @property \EasyWeChat\MiniProgram\Broadcast\Client $broadcast
|
||||
*/
|
||||
class Application extends ServiceContainer
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $providers = [
|
||||
Auth\ServiceProvider::class,
|
||||
DataCube\ServiceProvider::class,
|
||||
AppCode\ServiceProvider::class,
|
||||
Server\ServiceProvider::class,
|
||||
TemplateMessage\ServiceProvider::class,
|
||||
CustomerService\ServiceProvider::class,
|
||||
UniformMessage\ServiceProvider::class,
|
||||
ActivityMessage\ServiceProvider::class,
|
||||
OpenData\ServiceProvider::class,
|
||||
Plugin\ServiceProvider::class,
|
||||
Base\ServiceProvider::class,
|
||||
Express\ServiceProvider::class,
|
||||
NearbyPoi\ServiceProvider::class,
|
||||
OCR\ServiceProvider::class,
|
||||
Soter\ServiceProvider::class,
|
||||
Mall\ServiceProvider::class,
|
||||
SubscribeMessage\ServiceProvider::class,
|
||||
RealtimeLog\ServiceProvider::class,
|
||||
Search\ServiceProvider::class,
|
||||
Live\ServiceProvider::class,
|
||||
Broadcast\ServiceProvider::class,
|
||||
// Base services
|
||||
BasicService\Media\ServiceProvider::class,
|
||||
BasicService\ContentSecurity\ServiceProvider::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle dynamic calls.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return $this->base->$method(...$args);
|
||||
}
|
||||
}
|
||||
39
vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php
vendored
Normal file
39
vendor/overtrue/wechat/src/MiniProgram/Auth/AccessToken.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Auth;
|
||||
|
||||
use EasyWeChat\Kernel\AccessToken as BaseAccessToken;
|
||||
|
||||
/**
|
||||
* Class AccessToken.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class AccessToken extends BaseAccessToken
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $endpointToGetToken = 'cgi-bin/token';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCredentials(): array
|
||||
{
|
||||
return [
|
||||
'grant_type' => 'client_credential',
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
'secret' => $this->app['config']['secret'],
|
||||
];
|
||||
}
|
||||
}
|
||||
41
vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php
vendored
Normal file
41
vendor/overtrue/wechat/src/MiniProgram/Auth/Client.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Auth;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Auth.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get session info by code.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function session(string $code)
|
||||
{
|
||||
$params = [
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
'secret' => $this->app['config']['secret'],
|
||||
'js_code' => $code,
|
||||
'grant_type' => 'authorization_code',
|
||||
];
|
||||
|
||||
return $this->httpGet('sns/jscode2session', $params);
|
||||
}
|
||||
}
|
||||
32
vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php
vendored
Normal file
32
vendor/overtrue/wechat/src/MiniProgram/Auth/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Auth;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
!isset($app['access_token']) && $app['access_token'] = function ($app) {
|
||||
return new AccessToken($app);
|
||||
};
|
||||
|
||||
!isset($app['auth']) && $app['auth'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
53
vendor/overtrue/wechat/src/MiniProgram/Base/Client.php
vendored
Normal file
53
vendor/overtrue/wechat/src/MiniProgram/Base/Client.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Base;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get paid unionid.
|
||||
*
|
||||
* @param string $openid
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getPaidUnionid($openid, $options = [])
|
||||
{
|
||||
return $this->httpGet('wxa/getpaidunionid', compact('openid') + $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user phone number by code
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getPhoneNumber($code)
|
||||
{
|
||||
return $this->httpPostJson('wxa/business/getuserphonenumber', ['code' => $code]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Base/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Base;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['base'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
206
vendor/overtrue/wechat/src/MiniProgram/Broadcast/Client.php
vendored
Normal file
206
vendor/overtrue/wechat/src/MiniProgram/Broadcast/Client.php
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Broadcast;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author Abbotton <uctoo@foxmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add broadcast goods.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(array $goodsInfo)
|
||||
{
|
||||
$params = [
|
||||
'goodsInfo' => $goodsInfo,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxaapi/broadcast/goods/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset audit.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function resetAudit(int $auditId, int $goodsId)
|
||||
{
|
||||
$params = [
|
||||
'auditId' => $auditId,
|
||||
'goodsId' => $goodsId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxaapi/broadcast/goods/resetaudit', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resubmit audit goods.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function resubmitAudit(int $goodsId)
|
||||
{
|
||||
$params = [
|
||||
'goodsId' => $goodsId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxaapi/broadcast/goods/audit', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete broadcast goods.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $goodsId)
|
||||
{
|
||||
$params = [
|
||||
'goodsId' => $goodsId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxaapi/broadcast/goods/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update goods info.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(array $goodsInfo)
|
||||
{
|
||||
$params = [
|
||||
'goodsInfo' => $goodsInfo,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxaapi/broadcast/goods/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get goods information and review status.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getGoodsWarehouse(array $goodsIdArray)
|
||||
{
|
||||
$params = [
|
||||
'goods_ids' => $goodsIdArray,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/business/getgoodswarehouse', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get goods list based on status.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getApproved(array $params)
|
||||
{
|
||||
return $this->httpGet('wxaapi/broadcast/goods/getapproved', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add goods to the designated live room.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addGoods(array $params)
|
||||
{
|
||||
return $this->httpPost('wxaapi/broadcast/room/addgoods', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Room List.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*
|
||||
* @author onekb <1@1kb.ren>
|
||||
*/
|
||||
public function getRooms(int $start = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/business/getliveinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Playback List.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*
|
||||
* @author onekb <1@1kb.ren>
|
||||
*/
|
||||
public function getPlaybacks(int $roomId, int $start = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'action' => 'get_replay',
|
||||
'room_id' => $roomId,
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/business/getliveinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a live room.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createLiveRoom(array $params)
|
||||
{
|
||||
return $this->httpPost('wxaapi/broadcast/room/create', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Broadcast/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Broadcast/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Broadcast;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author Abbotton <uctoo@foxmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['broadcast'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
34
vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php
vendored
Normal file
34
vendor/overtrue/wechat/src/MiniProgram/CustomerService/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\CustomerService;
|
||||
|
||||
use EasyWeChat\OfficialAccount\CustomerService\Client;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['customer_service'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
140
vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php
vendored
Normal file
140
vendor/overtrue/wechat/src/MiniProgram/DataCube/Client.php
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\DataCube;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get summary trend.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function summaryTrend(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappiddailysummarytrend', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get daily visit trend.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function dailyVisitTrend(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappiddailyvisittrend', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get weekly visit trend.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function weeklyVisitTrend(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidweeklyvisittrend', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get monthly visit trend.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function monthlyVisitTrend(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidmonthlyvisittrend', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visit distribution.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function visitDistribution(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidvisitdistribution', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get daily retain info.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function dailyRetainInfo(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappiddailyretaininfo', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get weekly retain info.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function weeklyRetainInfo(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidweeklyretaininfo', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get monthly retain info.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function monthlyRetainInfo(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidmonthlyretaininfo', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visit page.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function visitPage(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappidvisitpage', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user portrait.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function userPortrait(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getweanalysisappiduserportrait', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unify query.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
protected function query(string $api, string $from, string $to)
|
||||
{
|
||||
$params = [
|
||||
'begin_date' => $from,
|
||||
'end_date' => $to,
|
||||
];
|
||||
|
||||
return $this->httpPostJson($api, $params);
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/DataCube/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\DataCube;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['data_cube'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
46
vendor/overtrue/wechat/src/MiniProgram/Encryptor.php
vendored
Normal file
46
vendor/overtrue/wechat/src/MiniProgram/Encryptor.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram;
|
||||
|
||||
use EasyWeChat\Kernel\Encryptor as BaseEncryptor;
|
||||
use EasyWeChat\Kernel\Exceptions\DecryptException;
|
||||
use EasyWeChat\Kernel\Support\AES;
|
||||
|
||||
/**
|
||||
* Class Encryptor.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Encryptor extends BaseEncryptor
|
||||
{
|
||||
/**
|
||||
* Decrypt data.
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\DecryptException
|
||||
*/
|
||||
public function decryptData(string $sessionKey, string $iv, string $encrypted): array
|
||||
{
|
||||
$decrypted = AES::decrypt(
|
||||
base64_decode($encrypted, false),
|
||||
base64_decode($sessionKey, false),
|
||||
base64_decode($iv, false)
|
||||
);
|
||||
|
||||
$decrypted = json_decode($decrypted, true);
|
||||
|
||||
if (!$decrypted) {
|
||||
throw new DecryptException('The given payload is invalid.');
|
||||
}
|
||||
|
||||
return $decrypted;
|
||||
}
|
||||
}
|
||||
129
vendor/overtrue/wechat/src/MiniProgram/Express/Client.php
vendored
Normal file
129
vendor/overtrue/wechat/src/MiniProgram/Express/Client.php
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Express;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author kehuanhuan <1152018701@qq.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function listProviders()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/express/business/delivery/getall');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createWaybill(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/order/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteWaybill(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/order/cancel', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getWaybill(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/order/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getWaybillTrack(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/path/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getBalance(string $deliveryId, string $bizId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/quota/get', [
|
||||
'delivery_id' => $deliveryId,
|
||||
'biz_id' => $bizId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getPrinter()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/printer/getall');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function bindPrinter(string $openid)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/printer/update', [
|
||||
'update_type' => 'bind',
|
||||
'openid' => $openid,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function unbindPrinter(string $openid)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/express/business/printer/update', [
|
||||
'update_type' => 'unbind',
|
||||
'openid' => $openid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Express/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Express;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author kehuanhuan <1152018701@qq.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['express'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
58
vendor/overtrue/wechat/src/MiniProgram/Live/Client.php
vendored
Normal file
58
vendor/overtrue/wechat/src/MiniProgram/Live/Client.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Live;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author onekb <1@1kb.ren>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get Room List.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @deprecated This method has been merged into `\EasyWeChat\MiniProgram\Broadcast`
|
||||
*/
|
||||
public function getRooms(int $start = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/business/getliveinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Playback List.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @deprecated This method has been merged into `\EasyWeChat\MiniProgram\Broadcast`
|
||||
*/
|
||||
public function getPlaybacks(int $roomId, int $start = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'action' => 'get_replay',
|
||||
'room_id' => $roomId,
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/business/getliveinfo', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Live/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Live/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Live;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author onekb <1@1kb.ren>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['live'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
87
vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php
vendored
Normal file
87
vendor/overtrue/wechat/src/MiniProgram/Mall/CartClient.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class CartClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 导入收藏.
|
||||
*
|
||||
* @param array $params
|
||||
* @param bool $isTest
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add($params, $isTest = false)
|
||||
{
|
||||
return $this->httpPostJson('mall/addshoppinglist', $params, ['is_test' => (int) $isTest]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户收藏信息.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function query($params)
|
||||
{
|
||||
return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'batchquery']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户收藏信息.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function queryByPage($params)
|
||||
{
|
||||
return $this->httpPostJson('mall/queryshoppinglist', $params, ['type' => 'getbypage']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收藏.
|
||||
*
|
||||
* @param string $openid
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete($openid, array $products = [])
|
||||
{
|
||||
if (empty($products)) {
|
||||
return $this->httpPostJson('mall/deletebizallshoppinglist', ['user_open_id' => $openid]);
|
||||
}
|
||||
|
||||
return $this->httpPostJson('mall/deleteshoppinglist', ['user_open_id' => $openid, 'sku_product_list' => $products]);
|
||||
}
|
||||
}
|
||||
48
vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php
vendored
Normal file
48
vendor/overtrue/wechat/src/MiniProgram/Mall/ForwardsMall.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
/**
|
||||
* Class Application.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*
|
||||
* @property \EasyWeChat\MiniProgram\Mall\OrderClient $order
|
||||
* @property \EasyWeChat\MiniProgram\Mall\CartClient $cart
|
||||
* @property \EasyWeChat\MiniProgram\Mall\ProductClient $product
|
||||
* @property \EasyWeChat\MiniProgram\Mall\MediaClient $media
|
||||
*/
|
||||
class ForwardsMall
|
||||
{
|
||||
/**
|
||||
* @var \EasyWeChat\Kernel\ServiceContainer
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @param \EasyWeChat\Kernel\ServiceContainer $app
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
return $this->app["mall.{$property}"];
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php
vendored
Normal file
37
vendor/overtrue/wechat/src/MiniProgram/Mall/MediaClient.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class MediaClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 更新或导入媒体信息.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function import($params)
|
||||
{
|
||||
return $this->httpPostJson('mall/importmedia', $params);
|
||||
}
|
||||
}
|
||||
75
vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php
vendored
Normal file
75
vendor/overtrue/wechat/src/MiniProgram/Mall/OrderClient.php
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class OrderClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 导入订单.
|
||||
*
|
||||
* @param array $params
|
||||
* @param bool $isHistory
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add($params, $isHistory = false)
|
||||
{
|
||||
return $this->httpPostJson('mall/importorder', $params, ['action' => 'add-order', 'is_history' => (int) $isHistory]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入订单.
|
||||
*
|
||||
* @param array $params
|
||||
* @param bool $isHistory
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update($params, $isHistory = false)
|
||||
{
|
||||
return $this->httpPostJson('mall/importorder', $params, ['action' => 'update-order', 'is_history' => (int) $isHistory]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单.
|
||||
*
|
||||
* @param string $openid
|
||||
* @param string $orderId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete($openid, $orderId)
|
||||
{
|
||||
$params = [
|
||||
'user_open_id' => $openid,
|
||||
'order_id' => $orderId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('mall/deleteorder', $params);
|
||||
}
|
||||
}
|
||||
68
vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php
vendored
Normal file
68
vendor/overtrue/wechat/src/MiniProgram/Mall/ProductClient.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ProductClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 更新或导入物品信息.
|
||||
*
|
||||
* @param array $params
|
||||
* @param bool $isTest
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function import($params, $isTest = false)
|
||||
{
|
||||
return $this->httpPostJson('mall/importproduct', $params, ['is_test' => (int) $isTest]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物品信息.
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function query($params)
|
||||
{
|
||||
return $this->httpPostJson('mall/queryproduct', $params, ['type' => 'batchquery']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序的物品是否可被搜索.
|
||||
*
|
||||
* @param bool $value
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setSearchable($value)
|
||||
{
|
||||
return $this->httpPostJson('mall/brandmanage', ['can_be_search' => $value], ['action' => 'set_biz_can_be_search']);
|
||||
}
|
||||
}
|
||||
44
vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php
vendored
Normal file
44
vendor/overtrue/wechat/src/MiniProgram/Mall/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Mall;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['mall'] = function ($app) {
|
||||
return new ForwardsMall($app);
|
||||
};
|
||||
|
||||
$app['mall.order'] = function ($app) {
|
||||
return new OrderClient($app);
|
||||
};
|
||||
|
||||
$app['mall.cart'] = function ($app) {
|
||||
return new CartClient($app);
|
||||
};
|
||||
|
||||
$app['mall.product'] = function ($app) {
|
||||
return new ProductClient($app);
|
||||
};
|
||||
|
||||
$app['mall.media'] = function ($app) {
|
||||
return new MediaClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
110
vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php
vendored
Normal file
110
vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/Client.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\NearbyPoi;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author joyeekk <xygao2420@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add nearby poi.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add(array $params)
|
||||
{
|
||||
$params = array_merge([
|
||||
'is_comm_nearby' => '1',
|
||||
'poi_id' => '',
|
||||
], $params);
|
||||
|
||||
return $this->httpPostJson('wxa/addnearbypoi', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update nearby poi.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(string $poiId, array $params)
|
||||
{
|
||||
$params = array_merge([
|
||||
'is_comm_nearby' => '1',
|
||||
'poi_id' => $poiId,
|
||||
], $params);
|
||||
|
||||
return $this->httpPostJson('wxa/addnearbypoi', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete nearby poi.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $poiId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/delnearbypoi', [
|
||||
'poi_id' => $poiId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get nearby poi list.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list(int $page, int $pageRows)
|
||||
{
|
||||
return $this->httpGet('wxa/getnearbypoilist', [
|
||||
'page' => $page,
|
||||
'page_rows' => $pageRows,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set nearby poi show status.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setVisibility(string $poiId, int $status)
|
||||
{
|
||||
if (!in_array($status, [0, 1], true)) {
|
||||
throw new InvalidArgumentException('status should be 0 or 1.');
|
||||
}
|
||||
|
||||
return $this->httpPostJson('wxa/setnearbypoishowstatus', [
|
||||
'poi_id' => $poiId,
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/NearbyPoi/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\NearbyPoi;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author joyeekk <xygao2420@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['nearby_poi'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
34
vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php
vendored
Normal file
34
vendor/overtrue/wechat/src/MiniProgram/OCR/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\OCR;
|
||||
|
||||
use EasyWeChat\OfficialAccount\OCR\Client;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author joyeekk <xygao2420@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['ocr'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
81
vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php
vendored
Normal file
81
vendor/overtrue/wechat/src/MiniProgram/OpenData/Client.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\OpenData;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author tianyong90 <412039588@qq.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* removeUserStorage.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function removeUserStorage(string $openid, string $sessionKey, array $key)
|
||||
{
|
||||
$data = ['key' => $key];
|
||||
$query = [
|
||||
'openid' => $openid,
|
||||
'sig_method' => 'hmac_sha256',
|
||||
'signature' => hash_hmac('sha256', json_encode($data), $sessionKey),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/remove_user_storage', $data, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* setUserStorage.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setUserStorage(string $openid, string $sessionKey, array $kvList)
|
||||
{
|
||||
$kvList = $this->formatKVLists($kvList);
|
||||
|
||||
$data = ['kv_list' => $kvList];
|
||||
$query = [
|
||||
'openid' => $openid,
|
||||
'sig_method' => 'hmac_sha256',
|
||||
'signature' => hash_hmac('sha256', json_encode($data), $sessionKey),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/set_user_storage', $data, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function formatKVLists(array $params)
|
||||
{
|
||||
$formatted = [];
|
||||
|
||||
foreach ($params as $name => $value) {
|
||||
$formatted[] = [
|
||||
'key' => $name,
|
||||
'value' => strval($value),
|
||||
];
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/OpenData/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\OpenData;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['open_data'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
67
vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php
vendored
Normal file
67
vendor/overtrue/wechat/src/MiniProgram/Plugin/Client.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Plugin;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @param string $appId
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function apply($appId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/plugin', [
|
||||
'action' => 'apply',
|
||||
'plugin_appid' => $appId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpPostJson('wxa/plugin', [
|
||||
'action' => 'list',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appId
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function unbind($appId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/plugin', [
|
||||
'action' => 'unbind',
|
||||
'plugin_appid' => $appId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
86
vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php
vendored
Normal file
86
vendor/overtrue/wechat/src/MiniProgram/Plugin/DevClient.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Plugin;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class DevClient.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class DevClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get users.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getUsers(int $page = 1, int $size = 10)
|
||||
{
|
||||
return $this->httpPostJson('wxa/devplugin', [
|
||||
'action' => 'dev_apply_list',
|
||||
'page' => $page,
|
||||
'num' => $size,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Agree to use plugin.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function agree(string $appId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/devplugin', [
|
||||
'action' => 'dev_agree',
|
||||
'appid' => $appId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refuse to use plugin.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function refuse(string $reason)
|
||||
{
|
||||
return $this->httpPostJson('wxa/devplugin', [
|
||||
'action' => 'dev_refuse',
|
||||
'reason' => $reason,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete rejected applications.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->httpPostJson('wxa/devplugin', [
|
||||
'action' => 'dev_delete',
|
||||
]);
|
||||
}
|
||||
}
|
||||
40
vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php
vendored
Normal file
40
vendor/overtrue/wechat/src/MiniProgram/Plugin/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Plugin;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers services on the given container.
|
||||
*
|
||||
* This method should only be used to configure services and parameters.
|
||||
* It should not get services.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['plugin'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['plugin_dev'] = function ($app) {
|
||||
return new DevClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
41
vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/Client.php
vendored
Normal file
41
vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/Client.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\RealtimeLog;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Real time log query.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function search(string $date, int $beginTime, int $endTime, array $options = [])
|
||||
{
|
||||
$params = [
|
||||
'date' => $date,
|
||||
'begintime' => $beginTime,
|
||||
'endtime' => $endTime,
|
||||
];
|
||||
|
||||
return $this->httpGet('wxaapi/userlog/userlog_search', $params + $options);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/RealtimeLog/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\RealtimeLog;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['realtime_log'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
35
vendor/overtrue/wechat/src/MiniProgram/Search/Client.php
vendored
Normal file
35
vendor/overtrue/wechat/src/MiniProgram/Search/Client.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Search;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Submit applet page URL and parameter information.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function submitPage(array $pages)
|
||||
{
|
||||
return $this->httpPostJson('wxa/search/wxaapi_submitpages', compact('pages'));
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Search/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Search/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Search;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['search'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
42
vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php
vendored
Normal file
42
vendor/overtrue/wechat/src/MiniProgram/Server/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Server;
|
||||
|
||||
use EasyWeChat\MiniProgram\Encryptor;
|
||||
use EasyWeChat\OfficialAccount\Server\Guard;
|
||||
use EasyWeChat\OfficialAccount\Server\Handlers\EchoStrHandler;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
!isset($app['encryptor']) && $app['encryptor'] = function ($app) {
|
||||
return new Encryptor(
|
||||
$app['config']['app_id'],
|
||||
$app['config']['token'],
|
||||
$app['config']['aes_key']
|
||||
);
|
||||
};
|
||||
|
||||
!isset($app['server']) && $app['server'] = function ($app) {
|
||||
$guard = new Guard($app);
|
||||
$guard->push(new EchoStrHandler($app));
|
||||
|
||||
return $guard;
|
||||
};
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php
vendored
Normal file
37
vendor/overtrue/wechat/src/MiniProgram/Soter/Client.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Soter;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <hxhsoft@foxmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function verifySignature(string $openid, string $json, string $signature)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/soter/verify_signature', [
|
||||
'openid' => $openid,
|
||||
'json_string' => $json,
|
||||
'json_signature' => $signature,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/MiniProgram/Soter/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\Soter;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <hxhsoft@foxmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['soter'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
192
vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php
vendored
Normal file
192
vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/Client.php
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\SubscribeMessage;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author hugo <rabbitzhang52@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $message = [
|
||||
'touser' => '',
|
||||
'template_id' => '',
|
||||
'page' => '',
|
||||
'data' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $required = ['touser', 'template_id', 'data'];
|
||||
|
||||
/**
|
||||
* Send a template message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(array $data = [])
|
||||
{
|
||||
$params = $this->formatMessage($data);
|
||||
|
||||
$this->restoreMessage();
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/subscribe/send', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatMessage(array $data = [])
|
||||
{
|
||||
$params = array_merge($this->message, $data);
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $this->message[$key] : $value;
|
||||
}
|
||||
|
||||
foreach ($params['data'] as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (\array_key_exists('value', $value)) {
|
||||
$params['data'][$key] = ['value' => $value['value']];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($value) >= 1) {
|
||||
$value = [
|
||||
'value' => $value[0],
|
||||
// 'color' => $value[1],// color unsupported
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$value = [
|
||||
'value' => strval($value),
|
||||
];
|
||||
}
|
||||
|
||||
$params['data'][$key] = $value;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore message.
|
||||
*/
|
||||
protected function restoreMessage()
|
||||
{
|
||||
$this->message = (new ReflectionClass(static::class))->getDefaultProperties()['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine templates and add them to your personal template library under your account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addTemplate(string $tid, array $kidList, string $sceneDesc = null)
|
||||
{
|
||||
$sceneDesc = $sceneDesc ?? '';
|
||||
$data = \compact('tid', 'kidList', 'sceneDesc');
|
||||
|
||||
return $this->httpPost('wxaapi/newtmpl/addtemplate', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete personal template under account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteTemplate(string $id)
|
||||
{
|
||||
return $this->httpPost('wxaapi/newtmpl/deltemplate', ['priTmplId' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get keyword list under template title.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplateKeywords(string $tid)
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/getpubtemplatekeywords', compact('tid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the public template under the category to which the account belongs.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplateTitles(array $ids, int $start = 0, int $limit = 30)
|
||||
{
|
||||
$ids = \implode(',', $ids);
|
||||
$query = \compact('ids', 'start', 'limit');
|
||||
|
||||
return $this->httpGet('wxaapi/newtmpl/getpubtemplatetitles', $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of personal templates under the current account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplates()
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/gettemplate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of the applet account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/getcategory');
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/SubscribeMessage/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\SubscribeMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['subscribe_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
101
vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php
vendored
Normal file
101
vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/Client.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\TemplateMessage;
|
||||
|
||||
use EasyWeChat\OfficialAccount\TemplateMessage\Client as BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
public const API_SEND = 'cgi-bin/message/wxopen/template/send';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $message = [
|
||||
'touser' => '',
|
||||
'template_id' => '',
|
||||
'page' => '',
|
||||
'form_id' => '',
|
||||
'data' => [],
|
||||
'emphasis_keyword' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $required = ['touser', 'template_id', 'form_id'];
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $offset, int $count)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/wxopen/template/library/list', compact('offset', 'count'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(string $id)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/wxopen/template/library/get', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add(string $id, array $keyword)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/wxopen/template/add', [
|
||||
'id' => $id,
|
||||
'keyword_id_list' => $keyword,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $templateId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/wxopen/template/del', [
|
||||
'template_id' => $templateId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplates(int $offset, int $count)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/wxopen/template/list', compact('offset', 'count'));
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/TemplateMessage/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\TemplateMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['template_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
140
vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php
vendored
Normal file
140
vendor/overtrue/wechat/src/MiniProgram/UniformMessage/Client.php
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\UniformMessage;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\OfficialAccount\TemplateMessage\Client as BaseClient;
|
||||
|
||||
class Client extends BaseClient
|
||||
{
|
||||
public const API_SEND = 'cgi-bin/message/wxopen/template/uniform_send';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'touser' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Weapp Attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $weappMessage = [
|
||||
'template_id' => '',
|
||||
'page' => '',
|
||||
'form_id' => '',
|
||||
'data' => [],
|
||||
'emphasis_keyword' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Official account attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mpMessage = [
|
||||
'appid' => '',
|
||||
'template_id' => '',
|
||||
'url' => '',
|
||||
'miniprogram' => [],
|
||||
'data' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Required attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $required = ['touser', 'template_id', 'form_id', 'miniprogram', 'appid'];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function formatMessage(array $data = [])
|
||||
{
|
||||
$params = array_merge($this->message, $data);
|
||||
|
||||
if (empty($params['touser'])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "touser" can not be empty!'));
|
||||
}
|
||||
|
||||
if (!empty($params['weapp_template_msg'])) {
|
||||
$params['weapp_template_msg'] = $this->formatWeappMessage($params['weapp_template_msg']);
|
||||
}
|
||||
|
||||
if (!empty($params['mp_template_msg'])) {
|
||||
$params['mp_template_msg'] = $this->formatMpMessage($params['mp_template_msg']);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatWeappMessage(array $data = [])
|
||||
{
|
||||
$params = $this->baseFormat($data, $this->weappMessage);
|
||||
|
||||
$params['data'] = $this->formatData($params['data'] ?? []);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatMpMessage(array $data = [])
|
||||
{
|
||||
$params = $this->baseFormat($data, $this->mpMessage);
|
||||
|
||||
if (empty($params['miniprogram']['appid'])) {
|
||||
$params['miniprogram']['appid'] = $this->app['config']['app_id'];
|
||||
}
|
||||
|
||||
$params['data'] = $this->formatData($params['data'] ?? []);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param array $default
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function baseFormat($data = [], $default = [])
|
||||
{
|
||||
$params = array_merge($default, $data);
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($default[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $default[$key] : $value;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/MiniProgram/UniformMessage/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\MiniProgram\UniformMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['uniform_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user