php - Inserting a Row into a Google Fusion Table, Using forms -


i trying set page allow visitors enter information posted directly google fusion table (rather mysql database).

i hear google getting rid of old fusion tables sql api, need conforms fusion tables api v. 1. understand supposed come post request in format like: "insert (column name) values (user-input response)," after trying many iterations of this, i'm not having success.

eventually, resorted copying sample code basic form input fusion tables, changing values own example table. still not working. here code - hoping experience in area might able evaluate. don't know i'm doing, guess.

<!doctype html> 

<style type="text/css">   body { font-family: arial; }  </style> <script src="https://apis.google.com/js/client.js?onload=initialize"></script> <script type="text/javascript">   // clientid , apikey available @   // https://code.google.com/apis/console. more information, see   // http://code.google.com/p/google-api-javascript-client/wiki/authentication.    var clientid = '424838770953.apps.googleusercontent.com';   var apikey = 'aizasybgfobbgu5x2lucnmdivfe-feptq--trpi';    var scopes = 'https://www.googleapis.com/auth/fusiontables';   var tableid = '1c9tcqteoog66rxbcqxnjmhderbijxuam5sgbhss';    // initialize client, set onclick listeners.   function initialize() {     gapi.client.setapikey(apikey);     document.getelementbyid('insert-data').onclick = insertdata;     window.settimeout(function() { auth(true); }, 1);   }    // run oauth 2.0 authorization.   function auth(immediate) {     gapi.auth.authorize({       client_id: clientid,       scope: scopes,       immediate: immediate     }, handleauthresult);   }    // handle results of oauth 2.0 flow.   function handleauthresult(authresult) {     var authorizebutton = document.getelementbyid('authorize-button');     var createtablebutton = document.getelementbyid('create-table');     if (authresult) {       authorizebutton.disabled = true;       createtablebutton.disabled = false;     } else {       authorizebutton.disabled = true;       authorizebutton.onclick = function() { auth(false); return false; };     }   }      // run request insert data.  runclientrequest({       path: '/fusiontables/v1/tables',        method: 'post'     },  function insertdata() {     var name = document.getelementbyid('name').value;     var age = document.getelementbyid('age').value;     var insert = [];     insert.push('insert ');     insert.push('1c9tcqteoog66rxbcqxnjmhderbijxuam5sgbhss');     insert.push(' (name, age) values (');     insert.push("'" + name + "', ");     insert.push(age);     insert.push(')');      body: 'insert'   }    // execute client request.   function runclientrequest(request, callback) {     var restrequest = gapi.client.request(request);     restrequest.execute(callback);   } </script> </head> <body> <h1> fusion tables javascript example </h1> <h2> (3) insert data </h2> <p>   insert data newly created table. </p> <pre>insert <span id="table-id-1">[table_id]</span> (name, age) values ([name],  [age])</pre> <label>name:</label> <input type="text" id="name"><br> <label>age:</label> <input type="age" id="age"><br> <input type="button" id="insert-data" value="insert data"> <p id="insert-data-output"><i>insert response goes here...</i></p><br> 


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -