message
This commit is contained in:
parent
2f75f83084
commit
9caf26e7cd
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Wechat;
|
||||
|
||||
class AccessToken
|
||||
{
|
||||
|
||||
protected $token;
|
||||
|
||||
public function __construct($app,string $token, $expiresIn)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
}
|
|
@ -48,7 +48,7 @@ class Base
|
|||
return $request;
|
||||
}
|
||||
|
||||
public function transformForGetAccessToken($uri, $params)
|
||||
public function transformForGetRequest($uri, $params)
|
||||
{
|
||||
$uri = new Uri($uri);
|
||||
foreach ($params as $param) {
|
||||
|
@ -81,7 +81,7 @@ class Base
|
|||
return $token;
|
||||
}
|
||||
|
||||
$request = $this->transformForGetAccessToken('gettoken', [
|
||||
$request = $this->transformForGetRequest('gettoken', [
|
||||
'corpid' => $config['corp_id'],
|
||||
'corpsecret' => $config['secret']
|
||||
]);
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace App\Wechat;
|
|||
|
||||
use App\Wechat\Work\Base;
|
||||
|
||||
class ExternalContact extends Base
|
||||
class ExternalContact
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -3,16 +3,26 @@
|
|||
namespace Wechat\Work;
|
||||
|
||||
|
||||
class Miniprogram extends Base
|
||||
class Miniprogram
|
||||
{
|
||||
protected $app = 'miniprogram';
|
||||
|
||||
public function code2Session($type = 'authorization_code')
|
||||
/**
|
||||
* @var Work
|
||||
*/
|
||||
protected $work;
|
||||
|
||||
public function __construct($work)
|
||||
{
|
||||
$url = "https://qyapi.weixin.qq.com/cgi-bin/miniprogram/jscode2session?js_code=$code&grant_type=$type");
|
||||
$request = $this->client->transformForJsonRequest($url);
|
||||
$resp = $this->client->send($request);
|
||||
return json_decode($resp->getBody(), true);
|
||||
$this->work = $work;
|
||||
}
|
||||
|
||||
public function code2Session($code,$type = 'authorization_code')
|
||||
{
|
||||
$request = $this->work->transformForGetRequest('miniprogram/jscode2session', [
|
||||
'js_code' => $code,
|
||||
'grant_type' => $type,
|
||||
]);
|
||||
return $this->work->request($request);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,10 +21,19 @@ class Work extends Base
|
|||
|
||||
/**
|
||||
* 群聊接口
|
||||
* @param string $id 群id
|
||||
*/
|
||||
public function chat($id)
|
||||
{
|
||||
return new Chat($id, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序接口
|
||||
* @return Miniprogram
|
||||
*/
|
||||
public function miniProgram(){
|
||||
return new Miniprogram($this);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user