smartoweb/flickroauth1

非官方的flickr API Oauth 1.0适配器

v0.3 2017-12-13 16:42 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:43:06 UTC


README

Flickr Oauth1客户端提供商,用于thephpleague/oauth1-client(见https://github.com/thephpleague/oauth1-client)。

安装

composer require smartoweb/flickroauth1

用法

用法与The League的OAuth客户端相同,使用smartoweb\OAuth1\Client\Server\Flickr作为提供商。

1/ 初始化并存储服务器类,检索并存储临时凭证,并将用户重定向到Flickr授权屏幕

   $server = new smartoweb\OAuth1\Client\Server\Flickr([
      'identifier'   => 'your-client-id',
      'secret'       => 'your-client-secret',
      'callback_uri' => 'http://callback.url/callback',
   ]);
   #...store $server for use it in callback_uri function
   $temporaryCredentials=$server->getTemporaryCredentials();
   #...store $temporaryCredentials for use it in callback_uri function
   $server->authorize($state);

2/ 在callback_uri函数中获取Oauth1 $token

   $oauth_token=!empty($_GET['oauth_token'])?$_GET['oauth_token']:'';
   $oauth_verifier=!empty($_GET['oauth_verifier'])?$_GET['oauth_verifier']:'';
   if ($oauth_token!='' && $oauth_verifier!='') {
      $server=#...stored $server
      $temporaryCredentials=#...stored $temporaryCredentials
      $token = $server->getTokenCredentials($temporaryCredentials, $oauth_token, $oauth_verifier);
      #...store $token  
   }