Closed testingCitytech closed 1 year ago
Your $url
object is not an array, it's a \OAuth\Common\Http\Uri\Uri
object. You normally don't need to get just the oauth_verifier
value at this point, but rather the whole URL to which to send your user. This can be cast to a string, to get the full URL. You could for example redirect a web browser user like this:
header("Location: $url");
(Oh, and you should delete your 6cc27cfb0c759011b11a48e456d8ba74
API key, as its secret has now been published publicly.)
@samwilson Thank you.
it is working but when I click "OK, I'LL AUTHORIZE IT" button not redirect to another page.
Please help me... This API Key is invalid just for example.
That's because you're passing false
as the $callbackUrl
. What happens when you try examples/get_auth_token.php in the browser? Does it work? That code adds a callback URL of itself. (Note that you need to create examples/config.php
before using the examples.)
This is index.php
require_once 'vendor/autoload.php'; $apiKey = "6cc27cfb0c759011b11a48e456d8ba8d"; $apiSecret = "6169a34168fae6b8"; $flickr = new \Samwilson\PhpFlickr\PhpFlickr($apiKey, $apiSecret); $storage = new \OAuth\Common\Storage\Memory(); $flickr->setOauthStorage($storage); $perm = 'write'; $callbackUrl = 'http://localhost/flickr/vendor/samwilson/phpflickr/examples/get_auth_token.php'; $url = $flickr->getAuthUrl($perm, $callbackUrl); header("Location: $url");
This is examples/get_auth_token.php
Getting accessToken & tokenSecret is blank, How to store accessToken & tokenSecret in session
$accessToken = ""; $accessTokenSecret = "";
Fatal error: Uncaught exception 'Samwilson\PhpFlickr\FlickrException' with message 'Unable to decode Flickr response to flickr.test.login request: oauth_problem=token_rejected' in C:\xampp\htdocs\flickr\vendor\samwilson\phpflickr\src\PhpFlickr.php:358 Stack trace: #0 C:\xampp\htdocs\flickr\vendor\samwilson\phpflickr\src\TestApi.php(31): Samwilson\PhpFlickr\PhpFlickr->request('flickr.test.log...', Array, true) #1 C:\xampp\htdocs\flickr\vendor\samwilson\phpflickr\examples\get_auth_token.php(63): Samwilson\PhpFlickr\TestApi->login() #2 {main} thrown in C:\xampp\htdocs\flickr\vendor\samwilson\phpflickr\src\PhpFlickr.php on line 358
Now what to do? Please help me.
Did you create examples/config.php
with valid values?
Is this working now?
This is my code:
`require_once 'vendor/autoload.php'; $apiKey = "6cc27cfb0c759011b11a48e456d8ba74"; $apiSecret = "6169a34168fae718"; $flickr = new \Samwilson\PhpFlickr\PhpFlickr($apiKey, $apiSecret);
$storage = new \OAuth\Common\Storage\Memory(); $flickr->setOauthStorage($storage);
$perm = 'write'; $callbackUrl = false; $url = $flickr->getAuthUrl($perm, $callbackUrl);`
am not getting 'oauth_verifier' From $flickr->getAuthUrl($perm, $callbackUrl);
My Output
OAuth\Common\Http\Uri\Uri Object ( [scheme:OAuth\Common\Http\Uri\Uri:private] => https [userInfo:OAuth\Common\Http\Uri\Uri:private] => [rawUserInfo:OAuth\Common\Http\Uri\Uri:private] => [host:OAuth\Common\Http\Uri\Uri:private] => api.flickr.com [port:OAuth\Common\Http\Uri\Uri:private] => 443 [path:OAuth\Common\Http\Uri\Uri:private] => /services/oauth/authorize [query:OAuth\Common\Http\Uri\Uri:private] => oauth_token=72157710566803341-1250e3b8a7496c87&perms=write [fragment:OAuth\Common\Http\Uri\Uri:private] => [explicitPortSpecified:OAuth\Common\Http\Uri\Uri:private] => [explicitTrailingHostSlash:OAuth\Common\Http\Uri\Uri:private] => )
How to get 'oauth_token' from this array?![demo php](https://user-images.githubusercontent.com/54580411/63765395-8a4f5900-c8e6-11e9-8c08-01f8c9e8266d.png)