如何通过Facebook API 2.1中的third_party_id获取用户ID(uid)

问题描述:

Facebook API 1.0-2.0具有FQL,因此我可以通过FQL获得ID. 但是FQL将在2.1版中删除.

Facebook API 1.0-2.0 has FQL, so I can get ID by FQL. But FQL will be removed in version 2.1.

  $result = self::getAPI()->api("fql", "GET", array('q' => 'select uid from user where third_party_id="'.$thirdPartyId.'"', 'access_token' => Const::APPACCESS_TOKEN));

那么问题是如何通过API 2.1中的third_party_id获取用户ID?

so question is how to get user id by third_party_id in API 2.1?

通过向此Graph API端点发送GET请求,您仍然可以通过facebook第三方ID获取facebook uid:

You could still get facebook uid by facebook third party id by sending GET request to this Graph API endpoint:

https://graph.facebook.com/[THIRD_PARTY_ID]?access_token=[APP_ACCESS_TOKEN]

https://graph.facebook.com/[THIRD_PARTY_ID]?access_token=[APP_ACCESS_TOKEN]

响应将包含两个字段:nameid,而id是您想要的.

The response will have two fields: name and id, and the id is what you want.