forked from thenbsp/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuery.php
More file actions
43 lines (35 loc) · 884 Bytes
/
Query.php
File metadata and controls
43 lines (35 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Thenbsp\Wechat\Menu;
use Thenbsp\Wechat\Bridge\Http;
use Thenbsp\Wechat\Wechat\AccessToken;
class Query
{
/**
* 接口地址
*/
const QUERY_URL = 'https://api.weixin.qq.com/cgi-bin/menu/get';
/**
* Thenbsp\Wechat\Wechat\AccessToken
*/
protected $accessToken;
/**
* 构造方法
*/
public function __construct(AccessToken $accessToken)
{
$this->accessToken = $accessToken;
}
/**
* 获取响应结果
*/
public function doQuery()
{
$response = Http::request('GET', static::QUERY_URL)
->withAccessToken($this->accessToken)
->send();
if( $response['errcode'] != 0 ) {
throw new \Exception($response['errmsg'], $response['errcode']);
}
return $response;
}
}