>백엔드 개발 >PHP 튜토리얼 >PHP 公众号的高级群发接口不能上传图文消息素材,返回errcode:-2 errmsg:''

PHP 公众号的高级群发接口不能上传图文消息素材,返回errcode:-2 errmsg:''

WBOY
WBOY원래의
2016-06-06 20:31:401230검색

POST数据到https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS...(ACCESS_TOKEN是我自己的),返回如下:
array
'errcode' => int -2
'errmsg' => string '' (length=0)

请问这是什么问题?

--------------------------- 原代码 ----------------------------
$news[] = array("thumb_media_id"=>$image_list[0], "author"=>"kxc", "title"=>"最新公告1", "content_source_url"=>"lejia51.com", "content"=>"--", "digest"=>"notice", "show_cover_pic"=>"1");

$news[] = array("thumb_media_id"=>$image_list[1], "author"=>"kxc", "title"=>"最新公告2", "content_source_url"=>"lejia51.com", "content"=>"--", "digest"=>"notice", "show_cover_pic"=>"0");

$url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" . $this->token();

$json = json_encode(array("articles"=>$news));

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);

$data = curl_exec($curl);

if (curl_errno($curl)) {
$this->write_file(curl_error($curl));
return null;
}

$result = json_decode($data, true);

curl_close($this->cur);

var_dump($result);

回复内容:

POST数据到https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=ACCESS...(ACCESS_TOKEN是我自己的),返回如下:
array
'errcode' => int -2
'errmsg' => string '' (length=0)

请问这是什么问题?

--------------------------- 原代码 ----------------------------
$news[] = array("thumb_media_id"=>$image_list[0], "author"=>"kxc", "title"=>"最新公告1", "content_source_url"=>"lejia51.com", "content"=>"--", "digest"=>"notice", "show_cover_pic"=>"1");

$news[] = array("thumb_media_id"=>$image_list[1], "author"=>"kxc", "title"=>"最新公告2", "content_source_url"=>"lejia51.com", "content"=>"--", "digest"=>"notice", "show_cover_pic"=>"0");

$url = "https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=" . $this->token();

$json = json_encode(array("articles"=>$news));

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);

$data = curl_exec($curl);

if (curl_errno($curl)) {
$this->write_file(curl_error($curl));
return null;
}

$result = json_decode($data, true);

curl_close($this->cur);

var_dump($result);

曾经看过一次类似的问题
别人最后用UTF8 解决了

建议参考下小懒人http://www.mptool.cn

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.