-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdbtickets_flickr_token_dance.php
85 lines (56 loc) · 1.12 KB
/
dbtickets_flickr_token_dance.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
#
include("include/init.php");
loadlib("flickr_api");
$method = "flickr.auth.getFrob";
$args = array();
$more = array(
'sign' => 1,
);
$rsp = flickr_api_call($method, $args, $more);
if (! $rsp['ok']){
dumper($rsp);
exit();
}
$perms = "delete";
$extra = null;
$frob = $rsp['rsp']['frob']['_content'];
$url = flickr_api_auth_url($perms, $extra, $frob);
echo $url . "\n";
$stdin = fopen('php://stdin', 'r');
$ok = 0;
while (1){
echo "can has auth: ";
$line = fgets($stdin);
$line = trim($line);
if (preg_match("/^y/i", $line)){
$ok = 1;
break;
}
if (preg_match("/^n/i", $line)){
break;
}
}
if (! $ok){
echo "okay, quitting\n";
exit();
}
$method = "flickr.auth.getToken";
$args = array(
'frob' => $frob,
);
$more = array(
'sign' => 1,
);
$rsp = flickr_api_call($method, $args, $more);
if (! $rsp['ok']){
dumper($rsp);
exit();
}
$token = $rsp['rsp']['auth']['token']['_content'];
echo "new token is {$token}\n";
exit();
?>