我可以t find good samples of using php google api with fusiontables, so this code absolutely doesn
工作。我如何理解有两种方法可以使用api - 通过curl和使用函数发送帖子查询,例如:$ service-> table-> listTable()。有人,请告诉我,这些功能和参数是否有一些清单?我ve tried find listTable() here https://developers.google.com/fusiontables/docs/v2/reference/ . I couldn
了解如何使用参考文献中描述的'属性'。也许存在一种简单的方法来创建带有描述的命名表和一个命令中的一列?
<?php
error_reporting(E_ALL);
ini_set('log_errors', 'On');
ini_set('error_log', 'error.log');
set_time_limit(0);
require_once '/vendor/autoload.php';
$clientId = 'sdsdsadfffdsfsadffsdasdf';
$clientSecret = 'difdsafasdasdsa_';
$redirectUrl = 'http://localhost/fusiontable/dorgen.php';
$client = new Google_Client();
$client->setClientId($clientId);
$client->setClientSecret($clientSecret);
$client->setRedirectUri($redirectUrl);
$client->setScopes(array('https://www.googleapis.com/auth/fusiontables'));
if (isset($_GET['code'])) {
$client->authenticate($_GET['code']);
$client->getAccessToken();
exit;
}
print '<a href="' . $client->createAuthUrl() . '">Authenticate</a>';
$service = new Google_Service_fusiontables($client);
$myCurl = curl_init();
curl_setopt_array($myCurl, array(
CURLOPT_URL => 'https://www.googleapis.com/fusiontables/v2/tables',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query(array('
"columns": [
{
"name": "Test"
}
],
"isExportable": true,
"name": "Trst",
"description": "Test"
')))
);
$response = curl_exec($myCurl);
curl_close($myCurl);
echo "Answer: ".$response;
print_r($service->table->listTable());