公開している融合テーブルにデータを挿入したいと思います。私は特にhttps://developers.google.com/fusiontables/docs/sample_codeに助けを求めた。http://code.google.com/p/fusion-tables-client-php/source/browse/trunk/samples/form_example.php。このスクリプトの実行に必要なファイル、つまりダウンロードしたclienlogin.php、file.php、sql.php、およびconstants.phpをダウンロードしました。スクリプトは実行されていますが、行が挿入されていないため、理由を見つけることができません。私は自分のコードを貼り付けました(その小さなコード..それを見て、私がコミットしているエラーを教えてください)。基本的には、ユーザフォームを使ってユーザ情報を収集した後、私の融合テーブルにデータを挿入したいと思っています。私はGoogleフォームを使用したくありません。この方向の助けや指導の助けがあれば助けになるでしょう。Google融合テーブルへの挿入
<html>
<?php
include('D:\xampp\htdocs\itpold\clientlogin.php');
include('D:\xampp\htdocs\itpold\sql.php');
include('D:\xampp\htdocs\itpold\file.php');
// Table id
$tableid = 3544282;
//Enter your username and password
$username = "[email protected]";
$password = "XYZ";
$token = ClientLogin::getAuthToken($username, $password);
$ftclient = new FTClientLogin($token);
// If the request is a post, insert the data into the table
if($_SERVER['REQUEST_METHOD'] == 'POST') {
// Insert form data into table
$insertresults = $ftclient->query(SQLBuilder::insert($tableid,
array('Name'=> $_POST['Name'],
'Location' => $_POST['Location'])));
$insertresults = explode("\n", $insertresults);
$rowid1 = $insertresults[1];
echo $rowid1 ;
}
?>
<head>
<title>Simple Form Example</title>
<style>
body { font-family: Arial, sans-serif; }
</style>
<script type="text/javascript">
// Simple form checking.
function check_form() {
if(document.getElementById('Name').value == '' ||
document.getElementById('Location').value == '') {
alert('Name and location required.');
return false;
}
return true;
}
</script>
</head>
<body >
<h1>Simple Form Example</h1>
<h2>Insert data</h2>
<form method="post" action="forms.php" onsubmit="return check_form();">
Name: <input type="text" name="Name" id="Name" /><br />
Result: <input type="text" name="Location" id="Location" /><br />
<input type="submit" value="Submit" />
</form>
<h2>Table data</h2>
<p>
<?php
// Show the data from table
$table_data = $ftclient->query(SQLBuilder::select($tableid));
$table_data = explode("\n", $table_data);
for($i = 0; $i < count($table_data); $i++) {
echo $table_data[$i] . '<br />';
}
?>
</p>
</body>
</html>