微信公共号自定义菜单。
Posted jiaoqing。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信公共号自定义菜单。相关的知识,希望对你有一定的参考价值。
/**微信生成菜单
* [addMennu description]
*/
public function addMennu(){
$token = $this->getToken();
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$token;
$SERVER_NAME = "http://".$_SERVER[‘SERVER_NAME‘];/*域名*/
$zhifu = $this->url."index.php?r=pay/index";
$fu = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$this->appid."&redirect_uri=".urlencode($zhifu)."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
$data = ‘{
"button": [
{
"name": "海宇",
"sub_button": [
{
"type":"view",
"name":"支付",
"url":"‘.$fu.‘"
}
]
}
]
}‘;
return $this->sendCurl($url,$data);
}
public function sendCurl($url1,$data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //绕过安全证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); //绕过安全证书
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
print_r($this->addMennu());
/**微信生成菜单 * [addMennu description] */ public function addMennu(){ $token = $this->getToken(); $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$token; $SERVER_NAME = "http://".$_SERVER[‘SERVER_NAME‘];/*域名*/ $huoqu = $this->url."indexs.php?r=agent/code"; $qianyue = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$this->appid."&redirect_uri=".urlencode($huoqu)."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"; $wdht = $this->url."indexs.php?r=mycontrct/code"; $myqy = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$this->appid."&redirect_uri=".urlencode($wdht)."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"; $zhifu = $this->url."index.php?r=pay/index"; $fu = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$this->appid."&redirect_uri=".urlencode($zhifu)."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"; $a = $this->url."index.php?r=agent/code"; $agent = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$this->appid."&redirect_uri=".urlencode($a)."&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect"; $data = ‘{ "button": [ { "name": "海宇", "sub_button": [ { "type": "view", "name": "租赁豪宅", "url": "http://m.haiyufc.com/rent/rentAll" }, { "type": "view", "name": "委托", "url": "http://m.haiyufc.com" }, { "type":"view", "name":"支付", "url":"‘.$fu.‘" } ] }, { "name": "合同", "sub_button": [ { "type": "miniprogram", "name": "租赁签约", "url":"‘.$qianyue.‘", "appid":"wx935e38107163e960", "pagepath":"pages/index/index?typeid=1" }, { "type":"miniprogram", "name":"经纪人登陆", "url":"‘.$agent.‘", "appid":"wx935e38107163e960", "pagepath":"pages/index/index?typeid=2" } ] }, { "name": "关于海宇", "sub_button": [ { "type":"view", "name":"税费计算器", "url":"http://m.haiyufc.com/Mortgage/sm.html" }, { "type":"view", "name":"房贷计算器", "url":"http://m.haiyufc.com/Mortgage/Dksl.html" }, { "type":"view", "name":"招贤纳士", "url":"http://m.eqxiu.com/s/BJUmXHfy?from=singlemessage&isappinstalled=0&share_level=1&from_user=85c218ad-ec68-4329-93d2-b8fef280ef07&from_id=26875fa5-55e2-4b93-8f1b-06988424d127&share_time=1526789738908", }, { "type":"click", "name":"权证知识", "key":"V1001_GOOD" } ] } ] }‘; return $this->sendCurl($url,$data); }
以上是关于微信公共号自定义菜单。的主要内容,如果未能解决你的问题,请参考以下文章