-1

I would like to use Facebook Credits with my Django Application.

In the Facebook Credits documentation, there is only a sample for the callback page in PHP (https://developers.facebook.com/blog/post/489/).

However, I would like to develop a callback in my Django application. I already created a view for the callback, but now I have no idea what Facebook sends me and how should I parse it.

I suppose it is some kind of POST HTTP request with some parameters I should parse, but how?

Thank you for all input.

1 Answers1

2

They send you a signed request which you need to parse. I'd suggest reading the rest of the facebook documentation if you're confused about what that means.

This guy has already done the php to python conversion for you: http://sunilarora.org/parsing-signedrequest-parameter-in-python-bas

Once you've parsed what they sent you, do exactly what they do in the php script. Then, you send json back to them. At the end of your view:

def fb_credits_callback(request):
    # parse with your parse function
    # handle request
    return HttpResponse(json.dumps(data))
Chris Lacasse
  • 1,502
  • 10
  • 10
  • Thank you for your answer. I built a mockup python view, however I'm having a hard time finding an equivalent for the PHP `$order_info = stripcslashes($payload['order_info']);` in Python. My doubt is related to whether this replaces all escape characters or just meaningful ones. Do you have any clue about this? –  Jan 29 '12 at 12:36
  • I think order_info = payload['order_info'].decode('string_escape') should do what you want. If that doesn't work you might have luck asking a completely new question. – Chris Lacasse Jan 30 '12 at 16:17