当前位置: 首页>>代码示例>>PHP>>正文


PHP apiClient::refreshToken方法代码示例

本文整理汇总了PHP中apiClient::refreshToken方法的典型用法代码示例。如果您正苦于以下问题:PHP apiClient::refreshToken方法的具体用法?PHP apiClient::refreshToken怎么用?PHP apiClient::refreshToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apiClient的用法示例。


在下文中一共展示了apiClient::refreshToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: refresh_access_token

 public function refresh_access_token($email = '')
 {
     if ($email == '') {
         return '';
     }
     $query = $this->db->query("SELECT refresh_token FROM " . TABLE_GOOGLE . " WHERE email=?", array($email));
     if (!isset($query->row['refresh_token'])) {
         return '';
     }
     $client = new apiClient();
     $client->setApplicationName(GOOGLE_APPLICATION_NAME);
     $client->setClientId(GOOGLE_CLIENT_ID);
     $client->setClientSecret(GOOGLE_CLIENT_SECRET);
     $client->setRedirectUri(GOOGLE_REDIRECT_URL);
     $client->setDeveloperKey(GOOGLE_DEVELOPER_KEY);
     $client->refreshToken($query->row['refresh_token']);
     $s = $client->getAccessToken();
     $a = json_decode($s);
     if (isset($a->{'access_token'})) {
         return $a->{'access_token'};
     }
     return '';
 }
开发者ID:buxiaoyang,项目名称:EmailArchive,代码行数:23,代码来源:google.php

示例2: header

if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['access_token'] = $client->getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['access_token'])) {
    $client->setAccessToken($_SESSION['access_token']);
    //json decode the session token and save it in a variable as object
    $sessionToken = json_decode($_SESSION['access_token']);
    //Save the refresh token (object->refresh_token) into a cookie called 'token' and make last for 1 month
    if (isset($sessionToken->refresh_token)) {
        //refresh token is only set after a proper authorisation
        $number_of_days = 30;
        $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days;
        setcookie('token', $sessionToken->refresh_token, $date_of_expiry);
    }
} else {
    if (isset($_COOKIE["token"])) {
        //if we don't have a session we will grab it from the cookie
        $client->refreshToken($_COOKIE["token"]);
        //update token
    }
}
if ($client->getAccessToken()) {
    $me = $plus->people->get('me');
    $optParams = array('maxResults' => 100);
    $activities = $plus->activities->listActivities('me', 'public', $optParams);
    $_SESSION['access_token'] = $client->getAccessToken();
} else {
    $authUrl = $client->createAuthUrl();
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:31,代码来源:google-plus-access.php


注:本文中的apiClient::refreshToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。