...
|
...
|
@@ -87,10 +87,11 @@ class Yohobuy |
|
|
*
|
|
|
* @param string $url 接口URL
|
|
|
* @param array $data 参数列表
|
|
|
* @param bool $returnJson 控制是否返回json格式数据
|
|
|
* @param int $timeout 超时时间
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public static function get($url, $data = array(), $timeout = 5)
|
|
|
public static function get($url, $data = array(), $returnJson = false, $timeout = 5)
|
|
|
{
|
|
|
if (isset($data['private_key'])) {
|
|
|
unset($data['private_key']);
|
...
|
...
|
@@ -104,7 +105,7 @@ class Yohobuy |
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
$result = curl_exec($ch);
|
|
|
if (!empty($result)) {
|
|
|
if (!$returnJson && !empty($result)) {
|
|
|
$result = json_decode($result, true);
|
|
|
}
|
|
|
curl_close($ch);
|
...
|
...
|
@@ -118,12 +119,13 @@ class Yohobuy |
|
|
*
|
|
|
* @param string $url 接口URL
|
|
|
* @param array $data 参数列表
|
|
|
* @param bool $returnJson 控制是否返回json格式数据
|
|
|
* @param int $timeout 超时时间
|
|
|
* @param array $header
|
|
|
* @param array $cookie
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public static function post($url, $data = array(), $timeout = 5, $header = array(), $cookie = array())
|
|
|
public static function post($url, $data = array(), $returnJson = false, $timeout = 5, $header = array(), $cookie = array())
|
|
|
{
|
|
|
$ch = curl_init($url);
|
|
|
|
...
|
...
|
@@ -151,7 +153,7 @@ class Yohobuy |
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
}
|
|
|
$result = curl_exec($ch);
|
|
|
if (!empty($result)) {
|
|
|
if (!$returnJson && !empty($result)) {
|
|
|
$result = json_decode($result, true);
|
|
|
}
|
|
|
curl_close($ch);
|
...
|
...
|
|