PHPoAuthLib
PHPoAuthLib copied to clipboard
Unable to request flickr api with extra arguments except method
If I want to fetch any API of flickr by passing arguments it's not possible. I am not able to request with extra parameters except $path in request method.
Code in Oauth1 directory filename Flickr.php:-
public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
{
$uri = $this->determineRequestUriFromPath('/', $this->baseApiUri);
$uri->addToQuery('method', $path);
if (!empty($this->format)) {
$uri->addToQuery('format', $this->format);
if ($this->format === 'json') {
$uri->addToQuery('nojsoncallback', 1);
}
}
$token = $this->storage->retrieveAccessToken($this->service());
$extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
$authorizationHeader = array(
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body)
);
$headers = array_merge($authorizationHeader, $extraHeaders);
return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
}
It should also accept one more parameter as $extraParams (array), which will include all params like ['per_page' = '10', 'user_id' => '232423@NO1'] in the above code like :-
Code:-
public function request($path, array $extraParams = array(), $method = 'GET', $body = null, array $extraHeaders = array())
{
$uri = $this->determineRequestUriFromPath('/', $this->baseApiUri);
$uri->addToQuery('method', $path);
if(!empty($extraParams)) {
foreach ($extraParams as $key => $value) {
$uri->addToQuery($key, $value);
}
}
if (!empty($this->format)) {
$uri->addToQuery('format', $this->format);
if ($this->format === 'json') {
$uri->addToQuery('nojsoncallback', 1);
}
}
$token = $this->storage->retrieveAccessToken($this->service());
$extraHeaders = array_merge($this->getExtraApiHeaders(), $extraHeaders);
$authorizationHeader = array(
'Authorization' => $this->buildAuthorizationHeaderForAPIRequest($method, $uri, $token, $body)
);
$headers = array_merge($authorizationHeader, $extraHeaders);
return $this->httpClient->retrieveResponse($uri, $body, $headers, $method);
}
Above code is just an example. We can even make another function only to fetch API that is requestAPI(params...) with same some as above.
I am new to GITHUB. If you will update flickr API, it will be very helpful. Thank you.