Oauth登录PHP以显示Fusion Table

时间:2012-04-07 00:22:56

标签: google-maps oauth-2.0 google-fusion-tables

我需要帮助我的PHP代码,因为我有一个项目,我有一个私有层Fusion表,并希望在我的网站上显示。我正在尝试使用OAuth,但它显示了我的外套。所以变量被捕获了吗?我已经带了http://code.google.com/p/fusion-tables-api/指南,但没有告诉我任何事情。 :(

<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 = "xxxxxx@gmail.com";
$password = "xxxx";
$token = ClientLogin::getAuthToken($username, $password);
$ftclient = new FTClientLogin($token);

$condition = $_POST["


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

1 个答案:

答案 0 :(得分:0)

您的代码不是使用OAuth,而是使用旧方法“ClientLogin”。如果您想使用OAuth,请按照OAuth guide from Fusion Tables

要让它发挥作用真的很简单:

  • API console of Google
  • 注册您的申请
  • 然后,您将用户重定向到Google授权页面
  • 从那里,用户被重定向回您的应用程序(在第一步中注册您的应用程序时指定的URL)。在此步骤中,授权令牌将发送到您的应用程序
  • 使用此令牌,您可以访问用户融合表。

但是按照指南,一切都会详细描述!