1.自定义菜单创建的问题
在使用微信公众平台的时候遇见的一些问题
创建菜单,微信公众平台只能创建三个菜单必须在同一个button下面
子菜单则可以创建多个最多5个
$data["button"] = array(
array(
"type" => "click",
"name" => "菜单A",
"key" => "caidan"
),
array(
"name" => "菜单B",
"sub_button" => array(
array(
"type" => "view",
"name" => "搜索",
"url" => "http://www.baidu.com"
),
),
),
array(
"type" => "click",
"name" => "用户信息",
"key" => "userdata",
),
);
- 发送至微信服务时 应该使用json 发送
$postData = json_encode($data, JSON_UNESCAPED_UNICODE);
-
获取openid的时候需要通过开放平台获取,互动消息需要使用服务器,但是可直接发送模板消息
-
php curl get代码
public function get($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($curl);
return $data;
}
- php curl post代码
public function post($url, $filedata)
{
$curl = curl_init();
if (class_exists('./CURLFile')) {
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
}
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
if (!empty($filedata)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $filedata);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
// 接受消息
$json = file_get_contents("php://input");
$json = json_decode($json, true);
print_r($json);
网友评论