简体   繁体   English

通过Foursquare Api V2获取user_id

[英]Getting the user_id through Foursquare Api V2

I'm working on a foursquare integration for a social good website, and I have everything working as I want it to, however I want to retrieve and store users foursquare user_id's so others can search for their friend. 我正在为一个社交商品网站进行Foursquare集成,并且我可以按需要进行所有工作,但是我想检索并存储用户foursquare user_id,以便其他人可以搜索他们的朋友。 I've been searching all day, but I can't seem to find an end point, am I missing something? 我整天都在搜寻,但似乎找不到终点,我是否缺少任何东西? Or does this has to be done through user search? 还是必须通过用户搜索来完成? What is then best to use, as I have their email, and full name. 最好使用什么,因为我有他们的电子邮件地址和全名。

I am using jmathai's foursquare-async php libary. 我正在使用jmathai的foursquare-async php库。 I think it should be easy but I just can't figure it out. 我认为应该很容易,但我无法弄清楚。

I've found the solution. 我找到了解决方案。 To get an users' details you should use the end point "users/self". 要获取用户的详细信息,您应该使用端点“用户/自己”。 I had tried this before but got an error message. 我之前曾尝试过此操作,但收到错误消息。 I think that was related to something else now. 我认为这与现在的其他事情有关。

After authenticating two lines are simply enough: 验证两行之后就足够了:

<?php       
$fsObj->get("/users/self");  
print_r($creds->response);  
?php>

This gives an json array containing all relevant information on the user, including last checkins, name, and id. 这将提供一个json数组,其中包含有关用户的所有相关信息,包括最后签入,姓名和ID。 'self' can here also be replaced by any user id you're authorized for on that moment. 在这里,“自己”也可以被您当时授权的任何用户ID代替。

For more information I'd recommend to visit Foursquare Api website 有关更多信息,建议您访问Foursquare Api网站

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

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