Skip to content

Commit

Permalink
add: miniprogram urlscheme
Browse files Browse the repository at this point in the history
  • Loading branch information
Player626 committed Mar 9, 2021
1 parent f27c757 commit cddaa32
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MiniProgram/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
* @property Auth\AccessToken $accessToken
* @property Auth\Client $auth
* @property AppCode\Client $appCode
* @property UrlScheme\Client $urlScheme
*/
class Application extends ServiceContainer
{
const Auth = 'auth';
const AppCode = 'appCode';
const UrlScheme = 'urlScheme';

protected $providers = [
Auth\ServiceProvider::class,
AppCode\ServiceProvider::class
AppCode\ServiceProvider::class,
UrlScheme\ServiceProvider::class
];
}
36 changes: 36 additions & 0 deletions src/MiniProgram/UrlScheme/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php


namespace EasySwoole\WeChat\MiniProgram\UrlScheme;


use EasySwoole\WeChat\Kernel\ServiceProviders;
use EasySwoole\WeChat\MiniProgram\BaseClient;

/**
* Class Client
* @package EasySwoole\WeChat\MiniProgram\UrlScheme
*/
class Client extends BaseClient
{
/**
* 获取小程序scheme码
* @param array $param
* @return mixed
* @throws \EasySwoole\WeChat\Kernel\Exceptions\HttpException
*/
public function generate(array $param = [])
{
$response = $this->getClient()
->setMethod('POST')
->setBody($this->jsonDataToStream($param))
->send($this->buildUrl(
'/wxa/generatescheme',
['access_token' => $this->app[ServiceProviders::AccessToken]->getToken()])
);

$this->checkResponse($response, $parseData);

return $parseData;
}
}
21 changes: 21 additions & 0 deletions src/MiniProgram/UrlScheme/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace EasySwoole\WeChat\MiniProgram\UrlScheme;

use EasySwoole\WeChat\MiniProgram\Application;
use Pimple\Container;
use Pimple\ServiceProviderInterface;

/**
* Class ServiceProvider
* @package EasySwoole\WeChat\MiniProgram\UrlScheme
*/
class ServiceProvider implements ServiceProviderInterface
{
public function register(Container $app)
{
$app[Application::UrlScheme] = function ($app) {
return new Client($app);
};
}
}

0 comments on commit cddaa32

Please sign in to comment.