以下示例用于获取微信的图文素材列表:
$data = '{"type":"news", "offset":50, "count":20 }'; $access_token = "0erCbg(此处省略112个字)DZrOR0PJBFLhAHAMQW"; $url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=".$access_token; // 发送数据 $ch = curl_init(); $timeout = 300; curl_setopt($ch, CURLOPT_URL, $url); // curl_setopt($ch, CURLOPT_REFERER, "http://upall.cn/"); // 伪装来路 curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // URL为SSL时添加这行可解决页面空白 $rs = curl_exec($ch); curl_close($ch); // 输出 $rs = json_decode($rs); echo '<pre>'; print_r($rs); echo '</pre>';