Caching Facebook tabs and decrypting the signed_request
I've been building a few Facebook tabs lately and the landing pages are static pages that change depending on whether or not you "Liked" the page. I need to decode the signed_request Facebook provides to determine if the user has liked the page. Since the page is static I'd like to cache the page. I'd prefer to cache the entire page and switch pre/post-like divs to display depending on the like开发者_JAVA百科 state via javascript.
The problem is that the signed_request needs the app secret to decode. So I can't do this decryption client side without revealing the app secret. Currently, I'm decrypting the signed_request on every request in the backend. This makes it impossible for me to cache the page.
The only other option I can think of is to do an AJAX request that passes the signed_request, decrypts it and sends back the JSON data. This is obviously an ugly solution.
Is there a way a better way to decrypt the signed_request that will allow me to cache the page?
Nope, there is no way to do that client side as you've rightly pointed out with out exposing your app secret: your AJAX request option is really the only way forward here.
精彩评论