我正在使用 Google API PHP 客户端。每次我尝试登录时,我都被迫授予应用程序权限。
下面是我的代码。我基本上是在访问 Google API for Analytics
require_once 'lib/apiClient.php';
require_once 'lib/contrib/apiAnalyticsService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Analytics");
$client->setClientId('7xxxx');
$client->setClientSecret('xxxx');
$client->setRedirectUri('xxxx');
$client->setDeveloperKey('xxxx');
$analytics = new apiAnalyticsService($client);
if (isset($_GET['logout'])) {
unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
$client->authenticate();
$_SESSION['token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()) {
$profileId = getProfileIds($analytics);
echo "<select>";
foreach ($profileId as $profiles) {
echo "<option value=\"" . $profiles['profileId'] . "\">" . $profiles['name'] .
"</option>";
}
echo "</select>";
} else {
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Connect Me!</a>";
}
我们可以将什么选项传递给createAuthUrl()?