【问题标题】:Insertion into google fusion table插入谷歌融合表
【发布时间】:2012-05-03 00:01:30
【问题描述】:

我想将数据插入到我的公开融合表中。我查看了 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>

【问题讨论】:

    标签: google-fusion-tables


    【解决方案1】:

    我怀疑这是您的表的权限问题。您是否确定您登录时使用的帐户设置为该表的编辑器?检查这一点的最简单方法是作为表的所有者进入 Fusion Tables,然后单击右上角的共享链接。

    【讨论】:

      【解决方案2】:

      通常,服务器无法向安全 URL 发送请求。有关如何解决问题的一些想法,请参阅以下 StackOverflow 帖子:

      Can't connect to HTTPS site using cURL. Returns 0 length content instead. What can I do?

      【讨论】:

        猜你喜欢
        • 2014-06-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多