账户链接期间FB机器人PSID检索

嗨,我需要一些指导如何检索页面范围ID(PSID)或发件人ID,同时通过帐户链接过程。

文档build议使用以下解决scheme,但是我不明白这是如何适合我的POST方法或我的代码中的任何地方,以便我可以将我的唯一公司ID与PSID /发件人ID链接。

curl -X GET "https://graph.facebook.com/v2.6/me?access_token=PAGE_ACCESS_TOKEN \ &fields=recipient \ &account_linking_token=ACCOUNT_LINKING_TOKEN" 

顺便说一下,以上的收件人价值是指什么?

感谢你的帮助!

按照以下stream程通过帐户链接获取PSID(sender.id)

步骤1 :通过从您的机器人发送button给用户启动login过程

 function sendAccountLinking(recipientId) { var messageData = { recipient: { id: recipientId }, message: { attachment: { type: "template", payload: { template_type: "button", text: "Welcome. Link your account.", buttons: [{ type: "account_link", url: SERVER_URL + "/authorize" }] } } } }; callSendAPI(messageData); } 

第2步:在你的服务器代码中有一个get方法,并获取account_linking_token和redirect_uri请求参数。

例如:

 /* * This path is used for account linking. The account linking call-to-action * (sendAccountLinking) is pointed to this URL. * */ app.get('/authorize', function (req, res) { console.log('%%%%%%%% AccountLinking Testing'); var accountLinkingToken = req.query.account_linking_token; var redirectURI = req.query.redirect_uri; console.log('%%%%%%%% /authorize called with accountLinkingToken %s, redirectURI %s', accountLinkingToken, redirectURI); // Authorization Code should be generated per user by the developer. This will // be passed to the Account Linking callback. var authCode = "1234567890"; // Redirect users to this URI on successful login var redirectURISuccess = redirectURI + "&authorization_code=" + authCode; res.render('authorize', { accountLinkingToken: accountLinkingToken, redirectURI: redirectURI, redirectURISuccess: redirectURISuccess }); }); 

步骤3:使用这个account_linking_token并进行GET调用,从get方法获取PSIN(sender.id)。

例如从你的httep.get电话

https://graph.facebook.com/v2.6/me?access_token=YOUR_PAGE_ACCESS_TOKEN&fields=recipient&account_linking_token=ACCOUNT_LINKING_TOKEN

响应将如下所示:{“recipient”:“xxxxxxxxxxxx”,“id”:“xxxxxxxxxxxxxx”}

其中收件人是PSID(sender.id),id是appID(pageid)

谢谢,Nagendra Prasad SBR。