我想将数据插入到我公开的融合表中。我特地向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。脚本正在运行但是没有插入行,我无法找到原因。我已经粘贴了我的代码(它是一个小代码..请看一下它,让我知道我提交的错误)。基本上我想在通过用户表单收集用户信息后将数据插入到我的融合表中。我不想使用谷歌表格。这方面的任何帮助/指示都会有所帮助。
<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 = "ABCD@gmail.com";
$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>
答案 0 :(得分:0)
通常,服务器无法向安全URL发送请求。有关如何解决问题的一些想法,请参阅以下StackOverflow帖子:
Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?
答案 1 :(得分:0)
我怀疑这是您的表的权限问题。您是否确保将您登录的帐户设置为此表的编辑器?检查此问题的最简单方法是作为表的所有者进入Fusion Tables,然后单击右上角的共享链接。