开发者

How to detect if a user has logged in to flickr?

开发者 https://www.devze.com 2022-12-22 05:29 出处:网络
What is the right way to find out if a user has logged in to Flickr? I have an iframe in my application which lets user\'s download their images from Flickr. But if the user is not logged into flickr,

What is the right way to find out if a user has logged in to Flickr? I have an iframe in my application which lets user's download their images from Flickr. But if the user is not logged into flickr, then flickr redirects me OUT of the iframe to the yahoo home page.

I would like to do the following: - Check if the user has logged into flickr, if开发者_开发问答 he has, then download his images in the iframe. - Else, open a new browser window which will let the user enter his flickr login credentials.

Any suggestions from the experts?


You should use the Flikr API. You need to setup proper flikr authentication in your app. According to the docs, the authentication should flow like this:

Our web based app has the api key '1234567890'. It has already registered a callback url for this key - 'http://viewr.com/auth.php'.

  • User visits http://viewr.com/ and clicks on the 'login' link.
  • This link points to http://flickr.com/services/auth/?api_key=1234567890&perms=read&api_sig=2f3870be274f6c49b3e31a0c6728957f.
  • The user is already logged in to flickr - they are asked if they wish to allow the application to have 'read' permissions to their photos.
  • The user clicks 'yes' and flickr updates it's auth database.
  • The user is redirected to http://viewr.com/auth.php?frob=abcxyz. -The app makes a background call to flickr.auth.getToken: http://flickr.com/services/rest/?method=flickr.auth.getToken&api_key=1234567890&frob=abcxzy&api_sig=3f3870be274f6c49b3e31a0c6728957f.
  • The call returns an auth token '334455'.
  • The application stores the auth token and creates a session for the user with a cookie which points to the user's auth token.
  • The application makes a background request to the flickr.people.getInfo to return information about the user, by calling http://flickr.com/services/rest/?method=flickr.people.getInfo&api_key=1234567890&auth_token=334455&api_sig=4f3870be274f6c49b3e31a0c6728957f.
0

精彩评论

暂无评论...
验证码 换一张
取 消