简体   繁体   English

在Android应用上使用Foursquare API

[英]Using Foursquare API on an Android app

I want to get user's data (check in, friend, etc) after they have logged in in my app. 我想获取用户登录我的应用程序后的数据(签到,朋友等)。

I used this code which is more or less the same of my app. 我使用了与我的应用程序大致相同的代码

I don't understand some things: 我不明白一些事情:

  1. What is the callback url? 什么是回调网址? Can I choose any website? 我可以选择任何网站吗?
  2. I can get the access token, now how can I get user's data? 我可以获取访问令牌,现在如何获取用户数据?
  3. What is the best choice to save this data? 保存此数据的最佳选择是什么?

The sample code you have referenced is for connecting to foursquare using the token flow . 您引用的示例代码用于使用令牌流连接到foursquare。 It is used for apps that do not have their own servers, and hence you do not need to have a website that you control. 它用于没有自己的服务器的应用程序,因此您不需要拥有自己控制的网站。 Your registered redirect URI can be a fake URL, which the user will be redirected to in the webview, at which point you can extract the access token from the URL. 您注册的重定向URI可以是伪URL,用户将在Web视图中被重定向到该URL,此时您可以从URL中提取访问令牌。

If you do have a website you control, the preferred method of connecting is the access code flow. 如果您拥有自己控制的网站,则首选的连接方法是访问代码流。 In this case, the callback url must be a website that you control. 在这种情况下,回调URL必须是您控制的网站。 This flow has the advantage that your client secret does not need to be distributed with your app, and so attackers cannot extract your secret from the app and use it to authenticate users. 此流程的优点是不需要与您的应用程序一起分发您的客户机密,因此攻击者无法从应用程序中提取您的机密并使用它来对用户进行身份验证。

Once you have the token, you'll be able to use the api endpoints , along with the access token, to make requests on behalf of the user. 获得令牌后,就可以使用api端点和访问令牌来代表用户发出请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM