Properties

$access_token

$access_token : string

访问AccessToken

Type

string

$currentMethod

$currentMethod : array

当前请求方法参数

Type

array

$isTry

$isTry : boolean

当前模式

Type

boolean

$GetAccessTokenCallback

$GetAccessTokenCallback : string

注册代替函数

Type

string

Methods

__construct()

__construct(array  $options) 

BasicWeChat constructor.

Parameters

array $options

getAccessToken()

getAccessToken() : string

获取访问accessToken

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

string

delAccessToken()

delAccessToken() : boolean

清理删除accessToken

Returns

boolean

callPostApi()

callPostApi(string  $url, array  $data, boolean  $isBuildJson = true) : array

接口通用POST请求方法

Parameters

string $url

接口URL

array $data

POST提交接口参数

boolean $isBuildJson

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

callGetApi()

callGetApi(string  $url) : array

接口通用GET请求方法

Parameters

string $url

接口URL

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array

createMiniPath()

createMiniPath(string  $path, integer  $width = 430, boolean  $auto_color = false, array  $line_color = array("r" => "0", "g" => "0", "b" => "0")) : array|string

获取小程序码(永久有效) 接口A: 适用于需要的码数量较少的业务场景

Parameters

string $path

不能为空,最大长度 128 字节

integer $width

二维码的宽度

boolean $auto_color

自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调

array $line_color

auto_color 为 false 时生效

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array|string

createMiniScene()

createMiniScene(string  $scene, string  $page, integer  $width = 430, boolean  $auto_color = false, array  $line_color = array("r" => "0", "g" => "0", "b" => "0")) : array|string

获取小程序码(永久有效) 接口B:适用于需要的码数量极多的业务场景

Parameters

string $scene

最大32个可见字符,只支持数字

string $page

必须是已经发布的小程序存在的页面

integer $width

二维码的宽度

boolean $auto_color

自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调

array $line_color

auto_color 为 false 时生效

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array|string

createDefault()

createDefault(string  $path, integer  $width = 430) : array|string

获取小程序二维码(永久有效) 接口C:适用于需要的码数量较少的业务场景

Parameters

string $path

不能为空,最大长度 128 字节

integer $width

二维码的宽度

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

array|string

httpGetForJson()

httpGetForJson(string  $url) : array

以GET获取接口数据并转为数组

Parameters

string $url

接口地址

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

httpPostForJson()

httpPostForJson(string  $url, array  $data, boolean  $buildToJson = true) : array

以POST获取接口数据并转为数组

Parameters

string $url

接口地址

array $data

请求数据

boolean $buildToJson

Throws

\WeChat\Exceptions\InvalidResponseException

Returns

array

registerApi()

registerApi(string  $url, string  $method, array  $arguments = array()) : mixed

注册当前请求接口

Parameters

string $url

接口地址

string $method

当前接口方法

array $arguments

请求参数

Throws

\WeChat\Exceptions\InvalidResponseException
\WeChat\Exceptions\LocalCacheException

Returns

mixed