Properties

$baseUri

$baseUri : 

Type

$httpClient

$httpClient : \GuzzleHttp\ClientInterface

Type

\GuzzleHttp\ClientInterface

$middlewares

$middlewares : array

Type

array

$handlerStack

$handlerStack : \GuzzleHttp\HandlerStack

Type

\GuzzleHttp\HandlerStack

$defaults

$defaults : array

Type

array

Methods

__construct()

__construct(\EasyWeChat\Kernel\ServiceContainer  $app) 

Client constructor.

三方接口有三个access_token,这里用的是suite_access_token.

Parameters

\EasyWeChat\Kernel\ServiceContainer $app

httpGet()

httpGet(string  $url, array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

GET request.

Parameters

string $url
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpPost()

httpPost(string  $url, array  $data = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

POST request.

Parameters

string $url
array $data

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpPostJson()

httpPostJson(string  $url, string|array  $data = array(), array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

JSON request.

Parameters

string $url
string|array $data
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

httpUpload()

httpUpload(string  $url, array  $files = array(), array  $form = array(), array  $query = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Upload file.

Parameters

string $url
array $files
array $form
array $query

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

request()

request(string  $url, string  $method = 'GET', array  $options = array()) : \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

Make a request.

Parameters

string $url
string $method
array $options

Returns

\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string

requestRaw()

requestRaw(string  $url, string  $method = 'GET', array  $options = array()) : \EasyWeChat\Kernel\Http\Response

Parameters

string $url
string $method
array $options

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

\EasyWeChat\Kernel\Http\Response

getHttpClient()

getHttpClient() : \GuzzleHttp\ClientInterface

Return GuzzleHttp\ClientInterface instance.

Returns

\GuzzleHttp\ClientInterface

setDefaultOptions()

setDefaultOptions(array  $defaults = array()) 

Set guzzle default settings.

Parameters

array $defaults

getDefaultOptions()

getDefaultOptions() : array

Return current guzzle default settings.

Returns

array

setHttpClient()

setHttpClient(\GuzzleHttp\ClientInterface  $httpClient) : $this

Set GuzzleHttp\Client.

Parameters

\GuzzleHttp\ClientInterface $httpClient

Returns

$this

pushMiddleware()

pushMiddleware(callable  $middleware, null|string  $name = null) : $this

Add a middleware.

Parameters

callable $middleware
null|string $name

Returns

$this

getMiddlewares()

getMiddlewares() : array

Return all middlewares.

Returns

array

setHandlerStack()

setHandlerStack(\GuzzleHttp\HandlerStack  $handlerStack) : $this

Parameters

\GuzzleHttp\HandlerStack $handlerStack

Returns

$this

getHandlerStack()

getHandlerStack() : \GuzzleHttp\HandlerStack

Build a handler stack.

Returns

\GuzzleHttp\HandlerStack

getPreAuthorizationUrl()

getPreAuthorizationUrl(string  $preAuthCode = '', string  $redirectUri = '', string  $state = '') : string

企业微信安装应用授权 url.

Parameters

string $preAuthCode

预授权码

string $redirectUri

回调地址

string $state

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

string

getPreAuthCode()

getPreAuthCode() : mixed

获取预授权码.

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

setSession()

setSession(string  $preAuthCode, array  $sessionInfo) : mixed

设置授权配置.

该接口可对某次授权进行配置.

Parameters

string $preAuthCode
array $sessionInfo

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

getPermanentByCode()

getPermanentByCode(string  $authCode) : mixed

获取企业永久授权码.

Parameters

string $authCode

临时授权码,会在授权成功时附加在redirect_uri中跳转回第三方服务商网站,或通过回调推送给服务商。长度为64至512个字节

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

getAuthorization()

getAuthorization(string  $authCorpId, string  $permanentCode) : mixed

获取企业授权信息.

Parameters

string $authCorpId
string $permanentCode

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

getManagers()

getManagers(string  $authCorpId, string  $agentId) : mixed

获取应用的管理员列表.

Parameters

string $authCorpId
string $agentId

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

getOAuthRedirectUrl()

getOAuthRedirectUrl(string  $redirectUri = '', string  $scope = 'snsapi_userinfo', string|null  $state = null) : string

获取登录url.

Parameters

string $redirectUri
string $scope
string|null $state

Returns

string

getUserByCode()

getUserByCode(string  $code) : mixed

第三方根据code获取企业成员信息.

Parameters

string $code

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

mixed

getUserByTicket()

getUserByTicket(string  $userTicket) : array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

第三方使用user_ticket获取成员详情.

Parameters

string $userTicket

Throws

\EasyWeChat\Kernel\Exceptions\InvalidConfigException

Returns

array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string

registerHttpMiddlewares()

registerHttpMiddlewares() 

Register Guzzle middlewares.

accessTokenMiddleware()

accessTokenMiddleware() : \Closure

Attache access token to request query.

Returns

\Closure

logMiddleware()

logMiddleware() : \Closure

Log the request.

Returns

\Closure

retryMiddleware()

retryMiddleware() : \Closure

Return retry middleware.

Returns

\Closure

fixJsonIssue()

fixJsonIssue(array  $options) : array

Parameters

array $options

Returns

array