Search code examples
google-mapsoauth-2.0google-fusion-tables

Oauth login PHP to show Fusion Table


I need help with my PHP code, as I have a project where I have a private layer Fusion tables, and want to show on my website. I'm trying to use OAuth, but it shows me the coat. So the variables are captured? I have taken http://code.google.com/p/fusion-tables-api/ guide, but do not show me anything. : (

<code>
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas { width: 500px; height: 400px; }
</style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?
sensor=false">
</script>
<script type="text/javascript">
var map;

var layer;
var tableid = 2102910;

function initialize() {
map = new google.maps.Map(document.getElementById('map_canvas'), {
center: new google.maps.LatLng(19.541451, -96.925632),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
});

layer = new google.maps.FusionTablesLayer(tableid);
layer.setQuery("SELECT 'geometry' FROM " + tableid);
layer.setMap(map);
}

</script>

</head>
<body onload="initialize();">

<div id="map_canvas"></div>

<div style="margin-top: 10px;">

</div>
<?php

include('clientlogin.php');
include('sql.php');
include('file.php');
$tableid = 2102910;
$username = "[email protected]";
$password = "xxxx";
$token = ClientLogin::getAuthToken($username, $password);
$ftclient = new FTClientLogin($token);

$condition = $_POST["


echo "These Projects are in ".$condition."";
?>
</body>
</html>`
<code>

Solution

  • Your code is not using OAuth, but the older method "ClientLogin". If you want to use OAuth, follow the OAuth guide from Fusion Tables.

    It is really simple, to get it to work:

    • Register your application at the API console of Google.
    • Then you redirect the user to the Google Authorization page
    • From there the user gets redirected back to your application (to the URL you specified when registering your application in the first step). In this step the authorization token is sent to your application
    • With this token, you can access the users fusion tables.

    But just follow the guide, everything is described in detail!