商家通常会使用多种渠道与客户交流,例如,网站、移动应用和 Messenger。用户在网站或移动应用中使用 Facebook 登录时,Facebook 会为特定 Facebook 应用创建一个编号,称为应用范围编号。用户通过 Messenger 与商家互动时,Facebook 会为与 Messenger 智能助手关联的特定主页创建一个编号,称为主页范围编号。这意味着,对于同一用户,不同交流渠道的编号是不一样的。请记住,用户在您的应用中通过 Facebook 登录时,会创建一个应用范围编号,而没有安装和通过您的应用登录的用户没有应用范围编号。
商家可能希望跨不同渠道为用户提供无缝的体验。例如,用户通过 Messenger 智能助手与商家交流时,如果商家能够识别出该用户是其 Facebook 应用(例如,具有 Facebook 登录的网站或移动应用)的现有客户,那么商家就能为用户提供更加个性化的体验。我们提供一个 API,用于跨同一商家拥有的应用和 Messenger 智能助手检索同一用户的编号。
首先,您必须让 Facebook 知道,您的应用与您的 Messenger 智能助手关联的主页由同一商业实体拥有。为此,您需要使用 Facebook 商务管理平台:
然后,您可以针对用户节点查询 ids_for_apps
连线或 ids_for_pages
连线,检索编号。
您首次调用 API 可能触发一次应用审核,该审核需要大约 48 小时。
本文档内容:
此 API 有几个主要用途:
ids_for_apps
GET /{user-id}/ids_for_apps ?access_token=[page_access_token] &appsecret_proof=[appsecret_proof]
GET /{user-id}/ids_for_apps ?app=10152368852405295 &access_token=[page_access_token] &appsecret_proof=[appsecret_proof]
ids_for_pages
GET /{user-id}/ids_for_pages ?access_token=[app_access_token] &appsecret_proof=[appsecret_proof]
GET /{user-id}/ids_for_pages ?page=380374449010653 &access_token=[app_access_token] &appsecret_proof=[appsecret_proof]
ids_for_apps
GET /{user-id}/ids_for_apps ?access_token=[app_access_token]
GET /{user-id}/ids_for_apps ?app=10152368852405295 &access_token=[app_access_token]
ids_for_pages
GET /{user-id}/ids_for_pages ?access_token=[page_access_token] &appsecret_proof=[appsecret_proof]
GET /{user-id}/ids_for_pages ?app=380374449010653 &access_token=[page_access_token] &appsecret_proof=[appsecret_proof]
GET /{user-id} ?fields=name,age_range,ids_for_apps,ids_for_pages &access_token=[app_access_token]
{ "name": "John Smith", "age_range": { "min": 21 }, "ids_for_apps": { "data": [ { "id": "10152368852405295", "app": { "category": "Business", "link": "https://www.facebook.com/games/?app_id=1419232575008550", "name": "John's Game App", "id": "1419232575008550" } }, { "id": "645195294", "app": { "link": "https://apps.facebook.com/johnsmovieappns/", "name": "JohnsMovieApp", "namespace": "johnsmovieappns", "id": "259773517400382" } } ], "paging": ... }, "ids_for_pages": { "data": [ { "id": "12345123", // The psid for the user for that page "page": { "category": "Musician", "link": "https://www.facebook.com/Johns-Next-Great-Thing-380374449010653/", "name": "John's Next Great Thing", "id": "380374449010653" } } ], "paging": ... }, "id": "645195294" }
GET /{user-id} ?fields=name,is_payment_enabled,ids_for_apps,ids_for_pages &access_token=[page_access_token] &appsecret_proof=[appsecrete_proof]
{ "name": "John Smith", "is_payment_enabled": true, "ids_for_apps": { "data": [ { "id": "10152368852405295", "app": { "category": "Business", "link": "https://www.facebook.com/games/?app_id=1419232575008550", "name": "John's Game App", "id": "1419232575008550" } }, { "id": "645195294", "app": { "link": "https://apps.facebook.com/johnsmovieappns/", "name": "JohnsMovieApp", "namespace": "johnsmovieappns", "id": "259773517400382" } } ], "paging": ... }, "ids_for_pages": { "data": [ { "id": "12345123", // The psid for the user for that page "page": { "category": "Musician", "link": "https://www.facebook.com/Johns-Next-Great-Thing-380374449010653/", "name": "John's Next Great Thing", "id": "380374449010653" } } ], "paging": ... }, "id": "645195294" }
商家仅可使用该 API 关联如下两者:商家的应用或主页的用户编号,商家拥有并代表商家维护的其他应用或主页的用户编号。例如,服务提供商不可使用该 API 支持多个客户。
为防止出现违反本政策的行为,您的 API 请求需要接受审核,并返回错误消息“(#200) Your business is currently going through review to access this API”([#200] 商家目前正在接受访问此 API 的审核)。