예제 #1
0
// if there's a stored token, check if it's expired, and refresh if it is
if ($access_token && $access_token->expire_time < time()) {
    $oauth_app = new YahooOAuthApplication($oauth_consumer_key, $oauth_consumer_secret, $oauth_application_id);
    $access_token = $oauth_app->refreshAccessToken($access_token);
    $access_token->expire_time = time() + $access_token->expires_in;
    try {
        $results = $db->query("UPDATE `oauth_tokens` \n            SET `token_json` = '%s' \n            WHERE `service` = 'yahoo' \n            AND `local_user_id` = '%s', \n            LIMIT 1;", json_encode($access_token), $local_user_id);
    } catch (Exception $e) {
        printf('<pre>%s</pre>', print_r($e, true));
        die;
    }
}
if ($access_token) {
    $oauth_app = new YahooOAuthApplication($oauth_consumer_key, $oauth_consumer_secret, null, null, $access_token);
    //yql is awesome http://developer.yahoo.com/yql/console/?q=select%20*%20from%20social.profile%20where%20guid%3Dme
    $response = $oauth_app->yql('select * from social.profile where guid=me');
    $profile_data = $response->query->results->profile;
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <link rel="stylesheet" href="stylesheet.css" type="text/css" media="screen" title="no title" charset="utf-8">
    </head>
    <body>
        
        <?php 
if (!$access_token) {
    ?>