Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqizjl committed Jul 26, 2018
1 parent 4b2dca7 commit c399f97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ class Note extends Controller
#### 使用facade
```php
use Naixiaoxin\ThinkWechat\Facade;
// 动态载入配置
// $config = [ 'app_id' = '' ...]
// $officialAccount = app('wechat.official_account',['config' => $config]);
// $officialAccount = Facade::officialAccount($config);

$officialAccount = Facade::officialAccount(); // 公众号

$work = Facade::work(); // 企业微信
$payment = Facade::payment(); // 微信支付
$openPlatform = Facade::openPlatform(); // 开放平台
Expand All @@ -69,6 +64,11 @@ $miniProgram = Facade::miniProgram(); // 小程序
$officialAccount = Facade::officialAccount('test'); // 公众号
```

以上均支持传入自定义账号+配置(注:这里的config和配置文件中账号的格式相同):例如
```php
$officialAccount = Facade::officialAccount('',$config); // 公众号
```

### Oauth登录中间件(ThinkPHP5.1.6+)
使用中间件情况下,config的oauth.callback可以随便写~,反正是直接获取了当前URL
```php
Expand Down
12 changes: 7 additions & 5 deletions src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

/**
* Class Facade.
*
* @author overtrue <[email protected]>
*/
class Facade extends ThinkFacade
{
/**
* 默认为 Server.
*
* @return string
*/
public static function getFacadeAccessor()
Expand All @@ -26,39 +28,39 @@ public static function getFacadeAccessor()
/**
* @return \EasyWeChat\OfficialAccount\Application
*/
public static function officialAccount($config = [], $name = '')
public static function officialAccount($name = '',$config = [])
{
return $name ? app('wechat.official_account.' . $name, $config) : app('wechat.official_account', $config);
}

/**
* @return \EasyWeChat\Work\Application
*/
public static function work($config = [], $name = '')
public static function work($name = '',$config = [])
{
return $name ? app('wechat.work.' . $name, $config) : app('wechat.work', $config);
}

/**
* @return \EasyWeChat\Payment\Application
*/
public static function payment($config = [], $name = '')
public static function payment($name = '',$config = [])
{
return $name ? app('wechat.payment.' . $name, $config) : app('wechat.payment', $config);
}

/**
* @return \EasyWeChat\MiniProgram\Application
*/
public static function miniProgram($config = [], $name = '')
public static function miniProgram($name = '',$config = [])
{
return $name ? app('wechat.mini_program.' . $name, $config) : app('wechat.mini_program', $config);
}

/**
* @return \EasyWeChat\OpenPlatform\Application
*/
public static function openPlatform($config = [], $name = '')
public static function openPlatform($name = '',$config = [])
{
return $name ? app('wechat.open_platform.' . $name, $config) : app('wechat.open_platform', $config);
}
Expand Down

0 comments on commit c399f97

Please sign in to comment.