Facebook signed_request Invalid

不羁的心 提交于 2019-12-13 06:12:03

问题


So I've been fiddling about with creating a Facebook Page App and am running into an obstacle.

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.

Example String

[signed_request] => ccskn7MGtWvG9XXAU5F8nE61aFy-PP-2Jmvz35iwtOo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTM4NjEyNTk5NCwicGFnZSI6eyJpZCI6IjM5ODYxMDQ0MDIxNDI2NiIsImxpa2VkIjpmYWxzZSwiYWRtaW4iOnRydWV9LCJ1c2VyIjp7ImNvdW50cnkiOiJ1cyIsImxvY2FsZSI6ImVuX1VTIiwiYWdlIjp7Im1pbiI6MjF9fX0

I did find this other question (Invalid base64 in Facebook signed_request documentation example), but after trying to add padding, still not gibberish results.

Any help is appreciated.


回答1:


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



来源:https://stackoverflow.com/questions/20366041/facebook-signed-request-invalid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!