Skip to content

Commit

Permalink
Param can be a string now
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier HAUSHERR committed Mar 2, 2012
1 parent ff15246 commit 01e3ec1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Client/WsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getConnection($name)
* @param array $headers
* @return array
*/
public function get($uri, Array $param = array(), $headers = array())
public function get($uri, Array $param = null, $headers = array())
{
return $this->createRequest('GET', $uri, $param, $headers);
}
Expand All @@ -108,7 +108,7 @@ public function get($uri, Array $param = array(), $headers = array())
* @param array $headers
* @return array
*/
public function post($uri, Array $param = array(), $headers = array())
public function post($uri, $param = null, $headers = array())
{
return $this->createRequest('POST', $uri, $param, $headers);
}
Expand All @@ -120,7 +120,7 @@ public function post($uri, Array $param = array(), $headers = array())
* @param array $headers
* @return array
*/
public function put($uri, Array $param = array(), $headers = array())
public function put($uri, Array $param = null, $headers = array())
{
return $this->createRequest('PUT', $uri, $param, $headers);
}
Expand All @@ -132,7 +132,7 @@ public function put($uri, Array $param = array(), $headers = array())
* @param array $headers
* @return array
*/
public function delete($uri, Array $param = array(), $headers = array())
public function delete($uri, Array $param = null, $headers = array())
{
return $this->createRequest('DELETE', $uri, $param, $headers);
}
Expand All @@ -146,7 +146,7 @@ public function delete($uri, Array $param = array(), $headers = array())
* @param array $headers
* @return WsQueryBase
*/
protected function createRequest($method, $uri, Array $param = array(), Array $headers = array())
protected function createRequest($method, $uri, $param = null, Array $headers = array())
{
if (is_null($this->active_connection))
{
Expand Down
2 changes: 1 addition & 1 deletion Logging/WsClientLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WsClientLogger implements WsLoggerInterface
/** @var array $queries Executed REST queries. */
public $queries = array();

public function logQuery($queryId, $method, Array $params, Array $stats)
public function logQuery($queryId, $method, $params, Array $stats)
{
$this->queries[$queryId] = array('method' => $method, 'param' => $params, 'stats' => $stats);
}
Expand Down
4 changes: 2 additions & 2 deletions Logging/WsLoggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ interface WsLoggerInterface
* Log Ws Queries
* @param string $queryId
* @param string $method
* @param array $params
* @param mixed $params
* @param array $stats
*/
public function logQuery($queryId, $method, Array $params, Array $stats);
public function logQuery($queryId, $method, $params, Array $stats);
}
4 changes: 2 additions & 2 deletions Query/WsQueryBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ abstract class WsQueryBase
* @param string $host
* @param string $url
* @param int $type
* @param array $param
* @param mixed $param
* @return resource
*/
public function __construct($method, $host, $url, $id = null, Array $param = array())
public function __construct($method, $host, $url, $id = null, $param = null)
{
$this->setMethod($method);
$this->host = $host;
Expand Down
6 changes: 5 additions & 1 deletion Query/WsQueryRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ protected function init()

// Options
curl_setopt($this->handle, CURLOPT_URL, $url);
curl_setopt($this->handle, CURLOPT_POSTFIELDS, $this->param);
curl_setopt($this->handle, CURLOPT_CONNECTTIMEOUT_MS, self::TIMEOUT);
curl_setopt($this->handle, CURLOPT_HEADER, true);
curl_setopt($this->handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->handle, CURLOPT_USERAGENT, 'OverBlog Rest Client');

if(!is_null($this->param))
{
curl_setopt($this->handle, CURLOPT_POSTFIELDS, $this->param);
}

if (self::DELETE === $this->method)
{
curl_setopt($this->handle, CURLOPT_CUSTOMREQUEST, $this->method);
Expand Down

0 comments on commit 01e3ec1

Please sign in to comment.