-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathflickr.php
43 lines (35 loc) · 1.37 KB
/
flickr.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* Example of retrieving an authentication token of the Flickr service
*
* @author And <[email protected]>
* @author Christian Mayer <[email protected]>
* @copyright Copyright (c) 2013 The authors
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Client\CurlClient;
use OAuth\Common\Storage\Session;
/**
* Bootstrap the example
*/
require_once __DIR__ . '/bootstrap.php';
// Session storage
$storage = new Session();
// Setup the credentials for the requests
$credentials = new Credentials(
$servicesCredentials[ 'flickr' ][ 'key' ],
$servicesCredentials[ 'flickr' ][ 'secret' ],
$currentUri
);
// Instantiate the Flickr service using the credentials, http client and storage mechanism for the token
$flickrService = $serviceFactory->createService('Flickr', $credentials, $storage);
if ($flickrService->isGlobalRequestArgumentsPassed()) {
$flickrService->retrieveAccessTokenByGlobReqArgs();
$xml = simplexml_load_string($flickrService->request('flickr.test.login'));
print "status: " . (string) $xml->attributes()->stat . "\n";
} elseif (!empty($_GET[ 'go' ]) && $_GET[ 'go' ] === 'go') {
header('Location: ' . $flickrService->getAuthorizationUri(['perms' => 'write']));
} else {
echo "<a href='$currentUri?go=go'>Login with Flickr!</a>";
}