Authored by whb

添加PC的api gzip

... ... @@ -152,9 +152,11 @@ class Yohobuy
* @parma mixed $cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
* @param bool $returnJson 控制是否返回json格式数据
* @param int $timeout 超时时间
* @param null $userAgent
* @param bool $useGzip 是否启用Gzip
* @return mixed
*/
public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5, $userAgent = null)
public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5, $userAgent = null, $useGzip = true)
{
// 销毁私钥参数
if (isset($data['private_key'])) {
... ... @@ -175,6 +177,9 @@ class Yohobuy
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($useGzip) {
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
}
if (!empty($userAgent)) {
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
}
... ...