我正在开发AdX卖家API。我想每天从API中提取数据,但问题是它始终显示在屏幕下方..
我想自动连接并随身携带所有数据。那么任何人都可以帮助我如何自动连接adx卖家API。我正在使用下面的代码..
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/adexchange.seller');
$client->setAccessType('online');
$client->setApprovalPrompt('auto');
$client->setAuthConfigFile('../client_secrets.json');
$service = new google_Service_AdExchangeSeller($client);
if (isset($_REQUEST['logout'])) {
unset($_SESSION['access_token']);
}
if (isset($_GET['code'])) {
echo 'hi i am in this';
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect = 'http://' . $_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF'];
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
exit;
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']){
$client->setAccessToken($_SESSION['access_token']);
}
else {
$authUrl = $client->createAuthUrl();
}
echo pageHeader('Ad Exchange Seller REST API sample');
echo '<div><div class="request">';
if (isset($authUrl)) {
echo $authUrl;
echo '<a class="login" href="' . $authUrl . '">Connect Me!</a>';
}
else {
echo 'i am in else';
echo '<a class="logout" href="?logout">Logout</a>';
};
echo '</div>';
if ($client->getAccessToken()) { }