当您说要"更新"谷歌纵横用户时,您想要"更新其当前位置",对吧?
对于某些Google服务,Google会在Google Code上设置Google API项目.在这种情况下,您很幸运,因为有一个谷歌纵横API,它描述了您可以使用REST界面执行的不同操作(REST始终兼容curl).这是他们更新用户位置的示例代码:
POST https://www.googleapis.com/latitude/v1/currentLocation?key=INSERT-YOUR-KEY
/* Authorization header here */
Content-Type: application/json
{
"data": {
"kind":"latitude#location",
"latitude":37.420352,
"longitude":-122.083389,
"accuracy":130,
"altitude":35
}
}
Run Code Online (Sandbox Code Playgroud)
在谷歌纵横API webside描述的全部细节.在开始编写代码之前,您需要获取API密钥,并且在实际更新用户位置之前,您需要进行OATH 2.0身份验证握手.
如果您不想自己编写身份验证代码,Google会提供几个预先打包的客户端库,包括.NET,GWT,Java,PHP,Python和Ruby.它们各自支持完整的API,包括身份验证.
Google有一个完整的示例,它使用Java API进行身份验证.按照http://samples.google-api-java-client.googlecode.com/hg/latitude-json-oauth-sample/instructions.html?r=default上的说明进行试用.
| 归档时间: |
|
| 查看次数: |
3228 次 |
| 最近记录: |