微信通过数据库创建菜单-PHP源码
1. [文件] menuCreate.php
"; //echo $data; ///echo ""; $MENU_URL= "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$ACC_TOKEN; $ch = curl_init($MENU_URL); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length:'.strlen($data))); $info = curl_exec($ch); //创建成功返回:{"errcode":0,"errmsg":"ok"} $menu = json_decode($info); var_dump($menu); /* if($menu->errmsg == "ok"){ echo "菜单创建成功"; }else{ echo "菜单创建失败"; } */ ?>
PHP之友评论