微信自定义菜单的创建/查询/取消php示例代码
微信公众帐号 服务号可以使用 自定义菜单功能。之前在创建菜单时一直失败,原因是$data 格式一直没有传正确,后来终于解决了。这里先记录下 顺便封装了一个类,便于自定义菜单的管理。此类仅仅是自定义菜单的管理类,并未涉及微信自定义回复和菜单事件的代码。 代码如下 public static $appid = null; // 申请得到的appid
public static $secret = null; // 申请得到的secret public static $getToken = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"; public static $createMenu = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="; public static $selMenu ="https://api.weixin.qq.com/cgi-bin/menu/get?access_token="; public static $delMenu = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token="; public static $opt = array( public $ACCESS_TOKEN = null; /**
$this->token(); $strMeau = '{ $ret = $this->HttpPost(self::$createMenu.$this->ACCESS_TOKEN,self::$opt,$strMeau); echo $ret; /**
$ret = $this->HttpGet(self::$selMenu.$this->ACCESS_TOKEN,self::$opt); echo $ret; /**
$ret = $this->HttpGet(self::$delMenu.$this->ACCESS_TOKEN,self::$opt); echo $ret; /**
$arrRet = json_decode($ret,true); $this->ACCESS_TOKEN = $arrRet['access_token']; /**
if ( !empty($opt) ) { $curl = curl_init($url); foreach ($setopt as $key => $value) { $responseText = curl_exec($curl); curl_close($curl); return $responseText; /**
if ( !empty($opt) ) { $curl = curl_init($url); foreach ($setopt as $key => $value) { $responseText = curl_exec($curl); curl_close($curl); return $responseText; 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |