I want to get a server timestamp from Facebook Instant. The only method allowing this appears to be get_signed_player_info(). It returns a string like this:
Eii6e636mz5J47sfqAYEK40jYAwoFqi3x5bxHkPG4Q4.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTUwMDM5ODY3NSwicGxheWVyX2lkIjoiMTI0OTUyNTMwMTc1MjIwMSIsInJlcXVlc3RfcGF5bG9hZCI6Im15X2ZpcnN0X3JlcXVlc3QifQ
Facebook says you need to decode it like this to be able to access the timestamp:
- Split the signature into two parts delimited by the ‘.’ character.
- Decode the first part (the encoded signature) with base64url encoding.
- Decode the second part (the response payload) with base64url encoding, which should be a string representation of a JSON object that has the following fields: ** algorithm - always equals to HMAC-SHA256 ** issued_at - a unix timestamp of when this response was issued. ** player_id - unique identifier of the player. ** request_payload - the requestPayload string you specified when calling FBInstant.player.getSignedPlayerInfoAsync.
How would I decode the second part with “base64url encoding”? I’ve tried to use this lua module, but it returns a garbled string, probably because it’s not “url safe”.