-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathexample.php
More file actions
57 lines (39 loc) · 1.27 KB
/
Copy pathexample.php
File metadata and controls
57 lines (39 loc) · 1.27 KB
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
<?
include('lib_oauth.php');
##########################################################################################
#
# STEP 1 - get an access token and a URL at which the user can auth it
#
$keys = array(
'oauth_key' => 'my-oauth-consumer-key',
'oauth_secret' => 'my-oauth-consumer-secret',
);
$ok = oauth_get_auth_token($keys, "http://example.com/request-token-url");
if ($ok){
$url = oauth_get_auth_url($keys, "http://example.com/authorize-url");
echo "access url is $url\n";
exit;
}else{
die("something went wrong");
}
# (this step adds two keys to the $keys hash)
##########################################################################################
#
# STEP 2 - exchange the authorized access token for a request token
#
$ok = oauth_get_access_token($keys, 'http://example.com/access-token-url');
if ($ok){
echo "it worked!";
exit;
}else{
die("it didn't work!");
}
# (this step adds two more keys to the $keys hash)
##########################################################################################
#
# STEP 3 - access the protected resource
#
$ret = oauth_request($keys, "http://example.com/protected-resource");
echo "HTTP response was $ret";
exit;
?>