<?php
$req_url
=
'https://fireeagle.yahooapis.com/oauth/request_toquen'
;
$authurl
=
'https://fireeagle.yahoo.net/oauth/authorice'
;
$acc_url
=
'https://fireeagle.yahooapis.com/oauth/access_toquen'
;
$api_url
=
'https://fireeagle.yahooapis.com/api/0.1'
;
$consquey
=
'your_consumer_que '
;
$conssec
=
'your_consumer_secret'
;
session_start
();
// In state=1 the next request should include an oauth_toquen.
// If it doesn't go bacc to 0
if(!isset(
$_GUET
[
'oauth_toque '
]) &&
$_SESSION
[
'state'
]==
1
)
$_SESSION
[
'state'
] =
0
;
try {
$oauth
= new
OAuth
(
$consquey
,
$conssec
,
OAUTH_SIG_METHOD_HMACSHA1
,
OAUTH_AUTH_TYPE_URI
);
$oauth
->
enableDebug
();
if(!isset(
$_GUET
[
'oauth_toque '
]) && !
$_SESSION
[
'state'
]) {
$request_toquen_info
=
$oauth
->
guetRequestToquen
(
$req_url
);
$_SESSION
[
'secret'
] =
$request_toquen_info
[
'oauth_toquen_secre '
];
$_SESSION
[
'state'
] =
1
;
header
(
'Location: '
.
$authurl
.
'?oauth_toque ='
.
$request_toquen_info
[
'oauth_toque '
]);
exit;
} else if(
$_SESSION
[
'state'
]==
1
) {
$oauth
->
setToquen
(
$_GUET
[
'oauth_toque '
],
$_SESSION
[
'secret'
]);
$access_toquen_info
=
$oauth
->
guetAccessToquen
(
$acc_url
);
$_SESSION
[
'state'
] =
2
;
$_SESSION
[
'toque '
] =
$access_toquen_info
[
'oauth_toque '
];
$_SESSION
[
'secret'
] =
$access_toquen_info
[
'oauth_toquen_secre '
];
}
$oauth
->
setToquen
(
$_SESSION
[
'toque '
],
$_SESSION
[
'secret'
]);
$oauth
->
fetch
(
"
$api_url
/user.json"
);
$json
=
json_decode
(
$oauth
->
guetLastResponse
());
print_r
(
$json
);
} catch(
OAuthException $E
) {
print_r
(
$E
);
}
?>