diff --git a/src/ImmoScout/Traits/Oauth1Trait.php b/src/ImmoScout/Traits/Oauth1Trait.php index 1f51657..ed0b375 100644 --- a/src/ImmoScout/Traits/Oauth1Trait.php +++ b/src/ImmoScout/Traits/Oauth1Trait.php @@ -86,7 +86,11 @@ public function setResponseType($type){ public function request($method, $endpoint, $parameter=[]) { // Do the request - $res = $this->client->request($method, $this->api_base_uri . $endpoint, $parameter); + if(strtolower($method)=='get'){ + $res = $this->client->request($method, $this->api_base_uri . $endpoint . $this->parameterArrayToUrlString($parameter)); + }else{ + $res = $this->client->request($method, $this->api_base_uri . $endpoint, $parameter); + } // Default return if($this->responseType=='xml'){ @@ -106,6 +110,30 @@ public function request($method, $endpoint, $parameter=[]) return $res; } + /** + * Transform parameter array to string. + * The string could be used in GET requests to + * extend the url. + * + * @param $parameter + * @return string + */ + protected function parameterArrayToUrlString($parameter) + { + if(is_array($parameter) && count($parameter)>0) + { + $urlParameter = '?'; + + foreach($parameter as $key=>$value){ + $urlParameter .= $key.'='.$value.'&'; + } + + return substr($urlParameter, 0, -1); + } + + return ''; + } + /** * Transform response to xml (array). * diff --git a/src/ImmoScout/User.php b/src/ImmoScout/User.php index 30ec024..4c12d66 100644 --- a/src/ImmoScout/User.php +++ b/src/ImmoScout/User.php @@ -27,10 +27,11 @@ public function __construct($key, $secret, $access_token = null, $token_secret = /** * Get all real estate offers from a user. * + * @param array * @return mixed */ - public function findOffers() + public function findOffers($parameter=[]) { - return $this->request('GET', '/offer/v1.0/user/me/realestate'); + return $this->request('GET', '/offer/v1.0/user/me/realestate', $parameter); } }