コード例 #1
0
    
    $client = new Google_Client();
    $client->setAssertionCredentials($credentials);
    if ($client->getAuth()->isAccessTokenExpired()) {
      $client->getAuth()->refreshTokenWithAssertion();
    }
    */
    $logService->log('DEBUG', 'Submitting sitemap', $sitemap, 'sitemapper');
    $client = new Google_Client();
    $client->setAuthConfigFile('client_secrets.json');
    $client->setClassConfig("Google_Auth_OAuth2", 'access_type', 'offline');
    $client->setRedirectUri('http://newsline.world/php/oauth2.php');
    $client->addScope(Google_Service_Webmasters::WEBMASTERS);
    $client->setApplicationName("Newsline World");
    $service = new Google_Service_Webmasters($client);
    $token_rec = $ds->getGoogleToken("auth");
    $token = null;
    if ($token_rec) {
        $token = $token_rec['token'];
    }
    if ($token) {
        $client->setAccessToken($token);
    }
    //$client->revokeToken();
    if ($client->isAccessTokenExpired()) {
        $refresh_token = $token_rec['refresh_token'];
        $client->refreshToken($refresh_token);
        $token = $client->getAccessToken();
        $ds->setGoogleToken("auth", $token, null);
    }
} catch (Exception $x) {