1. 程式人生 > >微信公共號自定義菜單。

微信公共號自定義菜單。

繞過 ram ons sta direct get 生成 lencod _id

/**微信生成菜單

* [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); }

微信公共號自定義菜單。