Parsing Facebook signed using java_ Request will return malformed JSON
•
Java
I'm trying to parse Facebook signed in dopost of java servlet_ request. I use Base64 of Commons - codec - 1.3 to decode signed requests
String signedRequest = (String) req.getParameter("signed_request"); String payload = signedRequest.split("[.]",2)[1]; payload = payload.replace("-","+").replace("_","/").trim(); String jsonString = new String(Base64.decodeBase64(payload.getBytes()));
When I system Out jsonstring its format is incorrect Sometimes it misses the end of JSON} sometimes it misses "} at the end of the string
How do I get the correct JSON response from Facebook?
Solution
Facebook is using Base64 for URL. You may be trying to decode text using standard Base64 algorithm
>You can add the required characters (padding, etc.) > you can use commons codec 1.5 (New Base64 (true)), where they add support for this coding
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码