Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
2a8d1aaf6b470f0b4f9304e6eb11d6a48189de09
1 parent
e84a598e
添加调用接口时的Gzip配置项
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
library/Api/Yohobuy.php
library/Api/Yohobuy.php
View file @
2a8d1aa
...
...
@@ -165,12 +165,14 @@ class Yohobuy
*
* @param string $url 接口URL
* @param array $data 参数列表
* @par
ma mixed
$cache 控制是否启用接口数据的缓存(时间单位为秒). 如3600表示缓存1小时, false表示不缓存
* @par
am bool
$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'
]))
{
...
...
@@ -191,6 +193,10 @@ 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
);
}
...
...
Please
register
or
login
to post a comment