Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
a7918e9d
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a7918e9d
编写于
6月 01, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- Test:微信公众号自定义菜单
上级
38ef7195
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
163 addition
and
0 deletion
+163
-0
src/service/wechat/WebAppService.php
src/service/wechat/WebAppService.php
+163
-0
未找到文件。
src/service/wechat/WebAppService.php
浏览文件 @
a7918e9d
...
...
@@ -440,6 +440,169 @@ class WebAppService extends Service
->
toArray
();
}
/**
* 自定义菜单 获取自定义菜单配置
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Getting_Custom_Menu_Configurations.html
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuGet
()
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/get?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
toArray
();
}
/**
* 自定义菜单 创建个性化菜单
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html
* @param array $data
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuAddConditional
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/addconditional?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
if
(
is_array
(
$data
))
$data
=
json_encode
(
$data
);
return
HttpService
::
instance
()
->
url
(
$url
)
->
post
()
->
data
(
$data
)
->
toArray
();
}
/**
* 自定义菜单 删除个性化菜单
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html
* @param array $data
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuDelConditional
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/delconditional?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
if
(
is_array
(
$data
))
$data
=
json_encode
(
$data
);
return
HttpService
::
instance
()
->
url
(
$url
)
->
post
()
->
data
(
$data
)
->
toArray
();
}
/**
* 自定义菜单 测试个性化菜单匹配结果
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Personalized_menu_interface.html
* @param array $data
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuTryMatch
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/trymatch?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
if
(
is_array
(
$data
))
$data
=
json_encode
(
$data
);
return
HttpService
::
instance
()
->
url
(
$url
)
->
post
()
->
data
(
$data
)
->
toArray
();
}
/**
* 自定义菜单 删除接口
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Deleting_Custom-Defined_Menu.html
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuDelete
()
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/delete?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
toArray
();
}
/**
* 自定义菜单 查询接口
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Querying_Custom_Menus.html
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
getCurrentSelfmenuInfo
()
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/get_current_selfmenu_info?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
toArray
();
}
/**
* 自定义菜单 创建接口
* https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html
* @param array $data
* @return array|bool|mixed|string
* @throws CacheException
* @throws CurlException
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @throws WeChatException
*/
public
function
menuCreate
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"
{
$this
->
api_url
}
cgi-bin/menu/create?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
if
(
is_array
(
$data
))
$data
=
json_encode
(
$data
);
return
HttpService
::
instance
()
->
url
(
$url
)
->
post
()
->
data
(
$data
)
->
toArray
();
}
/**
* 获取access_token信息
* @return array|bool|mixed|string|string[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录