Properties

$app

$app : \think\App

应用实例

Type

\think\App

$app_id

$app_id : 

公众号的唯一标识

Type

$app_secret

$app_secret : 

公众号的appsecret

Type

$redirect_uri

$redirect_uri : 

授权后重定向的回调链接地址, 请使用 urlEncode 对链接进行处理

Type

$response_type

$response_type : string

返回类型,请填写code

Type

string

$scope

$scope : string

Type

string

$state

$state : string

Type

string

$grant_type

$grant_type : string

Type

string

$cache

$cache : string

驱动方式

Type

string

$mch_key

$mch_key : 

商户平台设置的密钥key

Type

$mch_id

$mch_id : 

商户号

Type

Methods

__construct()

__construct(\think\App  $app) 

Service constructor.

Parameters

\think\App $app

instance()

instance(array  $args) : static

静态实例对象

Parameters

array $args

Returns

static

mchKey()

mchKey(string  $mchKey) : $this

Parameters

string $mchKey

Returns

$this

mchId()

mchId(string  $mchId) : $this

商户号

Parameters

string $mchId

Returns

$this

appId()

appId(string  $appId) : $this

公众号的唯一标识

Parameters

string $appId

Returns

$this

appSecret()

appSecret(string  $appSecret) : $this

公众号的appsecret

Parameters

string $appSecret

Returns

$this

redirectUri()

redirectUri(string  $redirectUri) : $this

授权后重定向的回调链接地址, 请使用 urlEncode 对链接进行处理

Parameters

string $redirectUri

Throws

\DtApp\ThinkLibrary\exception\DtaException

Returns

$this

scope()

scope(string  $scope) : $this

应用授权作用域,snsapi_base (不弹出授权页面,直接跳转,只能获取用户openid),snsapi_userinfo (弹出授权页面,可通过openid拿到昵称、性别、所在地。并且, 即使在未关注的情况下,只要用户授权,也能获取其信息 )

Parameters

string $scope

Throws

\DtApp\ThinkLibrary\exception\DtaException

Returns

$this

state()

state(string  $state) : $this

重定向后会带上state参数,开发者可以填写a-zA-Z0-9的参数值,最多128字节

Parameters

string $state

Returns

$this

cache()

cache(string  $cache) : $this

驱动方式

Parameters

string $cache

Returns

$this

oauth2()

oauth2() : void

网页授权 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html#0

Throws

\DtApp\ThinkLibrary\exception\DtaException

accessToken()

accessToken(string  $code, boolean  $is = true) : array|boolean|mixed|string

通过code换取网页授权access_token

Parameters

string $code
boolean $is

Throws

\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

refreshToken()

refreshToken(string  $refreshToken, boolean  $is = true) : array|boolean|mixed|string

刷新access_token(如果需要)

Parameters

string $refreshToken
boolean $is

Throws

\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

useInfo()

useInfo(string  $accessToken, string  $openid, string  $lang = "zh_CN", boolean  $is = true) : array|boolean|mixed|string

拉取用户信息(需scope为 snsapi_userinfo)

Parameters

string $accessToken
string $openid
string $lang
boolean $is

Returns

array|boolean|mixed|string

auth()

auth(string  $accessToken, string  $openid, boolean  $is = true) : array|boolean|mixed|string

检验授权凭证(access_token)是否有效

Parameters

string $accessToken
string $openid
boolean $is

Returns

array|boolean|mixed|string

share()

share(string  $url = '') : array

分享

Parameters

string $url

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException
\Exception

Returns

array

qrCode()

qrCode(array  $data) : array|boolean|mixed|string

生成二维码

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

messageTemplateSend()

messageTemplateSend(array  $data = array()) : array|boolean|mixed|string

发送模板消息

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

setIndustry()

setIndustry(string  $access_token, array  $data = array()) : boolean|mixed|string

设置所属行业 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html#0

Parameters

string $access_token
array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

boolean|mixed|string

shortUrl()

shortUrl(string  $long_url) : boolean

将一条长链接转成短链接

Parameters

string $long_url

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

boolean

fiNihPageSet()

fiNihPageSet(array  $data = array()) : array|boolean|mixed|string

连Wi-Fi完成页跳转小程序 https://developers.weixin.qq.com/doc/offiaccount/WiFi_via_WeChat/WiFi_mini_programs.html

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuGet()

menuGet() : array|boolean|mixed|string

自定义菜单 获取自定义菜单配置 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Getting_Custom_Menu_Configurations.html

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuAddConditional()

menuAddConditional(array  $data = array()) : array|boolean|mixed|string

自定义菜单 创建个性化菜单 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuDelConditional()

menuDelConditional(array  $data = array()) : array|boolean|mixed|string

自定义菜单 删除个性化菜单 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuTryMatch()

menuTryMatch(array  $data = array()) : array|boolean|mixed|string

自定义菜单 测试个性化菜单匹配结果 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuDelete()

menuDelete() : array|boolean|mixed|string

自定义菜单 删除接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Deleting_Custom-Defined_Menu.html

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

getCurrentSelfmenuInfo()

getCurrentSelfmenuInfo() : array|boolean|mixed|string

自定义菜单 查询接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Querying_Custom_Menus.html

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

menuCreate()

menuCreate(array  $data = array()) : array|boolean|mixed|string

自定义菜单 创建接口 https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html

Parameters

array $data

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string

payUnfIedOrder()

payUnfIedOrder(array  $array) : boolean|string

微信支付 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1

Parameters

array $array

Returns

boolean|string

h5Pay()

h5Pay(string  $prepay_id) : array

微信内H5调起支付

Parameters

string $prepay_id

Returns

array

initialize()

initialize() : $this

初始化服务

Returns

$this

getConfig()

getConfig() : $this

获取配置信息

Returns

$this

createNonceStr()

createNonceStr(integer  $length = 16) : string

Parameters

integer $length

Throws

\Exception

Returns

string

getAccessToken()

getAccessToken() : array|boolean|mixed|string|array<mixed,string>

获取access_token信息

Throws

\think\db\exception\DbException
\DtApp\ThinkLibrary\exception\DtaException

Returns

array|boolean|mixed|string|array<mixed,string>

paySign()

paySign(array  $array, boolean  $hmacsha256 = true) : string

生成支付签名

Parameters

array $array

参与签名的内容组成的数组

boolean $hmacsha256

是否使用 HMAC-SHA256算法,否则使用MD5

Returns

string

postXmlCurl()

postXmlCurl(  $xml) : boolean|string

Parameters

$xml

Returns

boolean|string