Every facebook example is always written first in php. For example, detecting a fan.
Some are never translated. For the record, here's a rails version. This goes in the controller (or even better, a helper).
p = params['signed_request'].split('.')[1]
json = Base64.decode64(p + "=" * (4 - p.size % 4))
data = ActiveSupport::JSON.decode(json)
liked = data["page"]["liked"]
Note the encoded string needs to be padded with = signs until it's a multiple of 4 bytes long.
The background on this is facebook has disabled static/fbml tabs from being added to fan pages. Instead, create an app and add the app to your page. This is to cover what people used to do with the fb:visible-to-connection fbml tag.
1 comment:
Great. Thanks a lot for this tutorial for Ruby on Rails :)
Post a Comment