Gaoming13\WechatPhpSdk\Api::get_materials PHP Method

get_materials() public method

获取素材列表
public get_materials ( string $type, string $offset, string $count ) : array(err,
$type string 素材的类型,图片(image)、视频(video)、语音 (voice)、图文(news)
$offset string 从全部素材的该偏移位置开始返回,0表示从第一个素材 返回
$count string 返回素材的数量,取值在1到20之间
return array(err,
    public function get_materials($type, $offset, $count)
    {
        $url = self::API_DOMAIN . 'cgi-bin/material/batchget_material?access_token=' . $this->get_access_token();
        $xml = sprintf('{"type":"%s","offset":"%s","count":"%s"}', $type, $offset, $count);
        $res = HttpCurl::post($url, $xml, 'json');
        // 异常处理: 获取时网络错误
        if ($res === false) {
            return Error::code('ERR_GET');
        }
        // 判断是否调用成功
        if ($res->errcode == 0) {
            return array(null, $res);
        } else {
            return array($res, null);
        }
    }