Facebook signed_request无效 [英] Facebook signed_request Invalid
问题描述
所以我一直在摆弄一个Facebook Page App,但遇到了麻烦.
So I've been fiddling about with creating a Facebook Page App and am running into an obstacle.
API文档( https://developers.facebook.com/docs/reference/login/signed-request/)表示它是json编码的base64编码的字符串,但我发现它经常不能正确解码(PHP).
The API Documentation (https://developers.facebook.com/docs/reference/login/signed-request/) indicates that it is a json encoded base64 encoded string, but I've found that more often then not it doesn't decode (PHP) properly.
示例字符串
[signed_request] => ccskn7MGtWvG9XXAU5F8nE61aFy-PP-2Jmvz35iwtOo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM4NjEyNTk5NCwicGFnZSI6eyJpZCI6IjM5ODYxMDQ0MDIxNDI2NiIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fX0
[signed_request] => ccskn7MGtWvG9XXAU5F8nE61aFy-PP-2Jmvz35iwtOo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM4NjEyNTk5NCwicGFnZSI6eyJpZCI6IjM5ODYxMDQ0MDIxNDI2NiIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fX0
我确实找到了另一个问题(无效的base64在Facebook sign_request文档中例如),但是在尝试添加填充后,结果仍然不乱.
I did find this other question (Invalid base64 in Facebook signed_request documentation example), but after trying to add padding, still not gibberish results.
感谢您的帮助.
推荐答案
要解析 signed_request
,首先必须在第一个点处将其拆分.
字符,然后在第二部分中,您必须分别用 +
和/
替换字符-
和 _
–之后base64对其进行解码.
To parse the signed_request
, first it must be split at the first dot .
character, and then in the second part you have to replace the characters -
and _
by +
and /
respectively – and after that base64-decode it.
关于您的问题,此内容记录在您所提及的文档顶部的链接文档中,此处为:
As for your question, where this is documented – in the document that is linked right on top of the document that you mentioned, here: https://developers.facebook.com/docs/facebook-login/using-login-with-games/#parsingsr
这篇关于Facebook signed_request无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!