Skip to content

Commit

Permalink
tweak dir. (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyoung authored and overtrue committed Aug 20, 2017
1 parent 97379f2 commit 4b1ba52
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 30 deletions.
3 changes: 1 addition & 2 deletions src/MiniProgram/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @property \EasyWeChat\MiniProgram\Auth\AccessToken $access_token
* @property \EasyWeChat\MiniProgram\DataCube\Client $data_cube
* @property \EasyWeChat\MiniProgram\AppCode\Client $app_code
* @property \EasyWeChat\MiniProgram\Sns\Client $sns
* @property \EasyWeChat\MiniProgram\Auth\Auth $auth
* @property \EasyWeChat\OfficialAccount\Server\Guard $server
* @property \EasyWeChat\MiniProgram\Encryptor $encryptor
* @property \EasyWeChat\MiniProgram\TemplateMessage\Client $template_message
Expand All @@ -38,7 +38,6 @@ class Application extends ServiceContainer
Auth\ServiceProvider::class,
DataCube\ServiceProvider::class,
AppCode\ServiceProvider::class,
Sns\ServiceProvider::class,
Server\ServiceProvider::class,
TemplateMessage\ServiceProvider::class,
CustomerService\ServiceProvider::class,
Expand Down
41 changes: 41 additions & 0 deletions src/MiniProgram/Auth/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* 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 <[email protected]>
*/
class Auth extends BaseClient
{
/**
* Get session info by code.
*
* @param string $code
*
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
*/
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);
}
}
4 changes: 4 additions & 0 deletions src/MiniProgram/Auth/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ public function register(Container $app)
!isset($app['access_token']) && $app['access_token'] = function ($app) {
return new AccessToken($app);
};

$app['auth'] = function ($app) {
return new Auth($app);
};
}
}
28 changes: 0 additions & 28 deletions src/MiniProgram/Sns/ServiceProvider.php

This file was deleted.

0 comments on commit 4b1ba52

Please sign in to comment.