|
@@ -65,7 +65,7 @@ class HttpService
|
|
* @param int $timeout 超时秒数
|
|
* @param int $timeout 超时秒数
|
|
* @return bool|string
|
|
* @return bool|string
|
|
*/
|
|
*/
|
|
- public static function request($url, $method = 'get', $data = array(), $header = false, $timeout = 15)
|
|
|
|
|
|
+ public static function request($url, $method = 'get', $data = array(), $header = false, $timeout = 15,$type='array')
|
|
{
|
|
{
|
|
self::$status = null;
|
|
self::$status = null;
|
|
self::$curlError = null;
|
|
self::$curlError = null;
|
|
@@ -76,7 +76,16 @@ class HttpService
|
|
//请求方式
|
|
//请求方式
|
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
|
|
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
|
|
//post请求
|
|
//post请求
|
|
- if ($method == 'POST') curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
|
|
|
+ if ($method == 'POST')
|
|
|
|
+ {
|
|
|
|
+ if($type=='array') {
|
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//超时时间
|
|
//超时时间
|
|
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
|
|
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
|
|
//设置header头
|
|
//设置header头
|