From 440e65004dc12a2d0615ba4b511c27b1dcdb5d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E5=BD=93=E8=8B=97=E5=84=BF?= Date: Mon, 15 Apr 2013 10:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9oauth=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E8=85=BE=E8=AE=AF=E5=BE=AE=E5=8D=9A?= =?UTF-8?q?=E5=92=8C=E6=96=B0=E6=B5=AA=E5=BE=AE=E5=8D=9A=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E3=80=82=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E8=AF=B7=E7=94=A8=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84=E4=B8=94?= =?UTF-8?q?=E5=89=8D=E9=9D=A2=E8=AE=B8=E6=B7=BB=E5=8A=A0@=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Org/Oauth/Driver.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Library/Org/Oauth/Driver.php b/Library/Org/Oauth/Driver.php index 388901af..806f155a 100644 --- a/Library/Org/Oauth/Driver.php +++ b/Library/Org/Oauth/Driver.php @@ -172,8 +172,7 @@ abstract class Driver { * @param string $method 请求方法GET/POST * @return array $data 响应数据 */ - protected function http($url, $params, $method = 'GET', $header = []){ - $vars = http_build_query($params); + protected function http($url, $params, $method = 'GET', $header = [], $multi = false){ $opts = array( CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => 1, @@ -185,12 +184,14 @@ abstract class Driver { /* 根据请求类型设置特定参数 */ switch(strtoupper($method)){ case 'GET': - $opts[CURLOPT_URL] = $url . '?' . $vars; + $opts[CURLOPT_URL] = $url . '?' . http_build_query($params); break; case 'POST': + //判断是否传输文件 ++ $params = $multi ? $params : http_build_query($params); $opts[CURLOPT_URL] = $url; $opts[CURLOPT_POST] = 1; - $opts[CURLOPT_POSTFIELDS] = $vars; + $opts[CURLOPT_POSTFIELDS] = $params; break; default: throw new Exception('不支持的请求方式!'); @@ -210,7 +211,7 @@ abstract class Driver { * 抽象方法,在SNSSDK中实现 * 组装接口调用参数 并调用接口 */ - abstract protected function call($api, $param = '', $method = 'GET'); + abstract protected function call($api, $param = '', $method = 'GET', $multi = false); /** * 抽象方法,在SNSSDK中实现