KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
For those willing to use the Zend_OAuth_Consumer solution, which I highly recommend, as it handles all the trivial steps needed to process an OAuth request, and all the difficult procedures that follow the response, here is my working code: 1) Establish the consumer instance: $consumer = new Zend_Oauth_Consumer(array( 'callbackUrl' => FLICKR_REDIRECT_URL /* from my app settings */, 'siteUrl' => 'http://www.flickr.com/services/oauth', 'consumerKey' => FLICKR_API_KEY, 'consumerSecret' => FLICKR_API_SECRET, 'requestTokenUrl' => FLICKR_REQUEST_TOKEN_URL /* www.flickr.com/services/oauth/request_token */, 'accessTokenUrl' => FLICKR_ACCESS_TOKEN_URL /* www.flickr.com/services/oauth/access_token */, 'authorizeUrl' => FLICKR_AUTHORIZE_URL /* www.flickr.com/services/oauth/authorize */ )); 2) Get the request token and store it in a $_SESSION variable (or use whatever other storage mechanism you want). Be sure to serialize the return object as a string for the session variable: $token = $consumer->getRequestToken(); $_SESSION['FLICKR_REQUEST_TOKEN'] = serialize($token); 3) Where I had issues setting the permissions, use the consumer instance's method to redirect, and set your perms at this point (i.e. 'read', 'write', 'delete', etc...): $consumer->redirect(array("perms" => FLICKR_API_PERMS /* 'read', 'write', 'delete', etc... */)); 4) On the page that you redirected to (i.e. FLICKR_REDIRECT_URL), create a new consumer instance, and now grab an access token, store it in the $_SESSION, and then unset the session request token variable: $consumer = new Zend_Oauth_Consumer(array( 'callbackUrl' => FLICKR_REDIRECT_URL /* from my app settings */, 'siteUrl' => 'http://www.flickr.com/services/oauth', 'consumerKey' => FLICKR_API_KEY, 'consumerSecret' => FLICKR_API_SECRET,
Tags (comma-separated)
Save Edits
Cancel