Wednesday, 14 August 2013

Facebook Realtime Updates Callback POST

Facebook Realtime Updates Callback POST

I am having a heck of a time getting the facebook realtime updates to work
correctly as I migrate to the local currency update.
I have created a page to handle the callbacks of the RTU and have
successfully authenticated with the hub challenge.
The process gets through the original verification, then the page appears
to get hit again, but it is dying every time when I try to get the post
data via Request.Form. I have put in a debugging section to try and step
through the Request.Form.Keys but it is coming up empty.
I have tried to identify a way to test it via the graph api POST function
but have had no luck there either.
if (Request.HttpMethod.Equals("GET", StringComparison.OrdinalIgnoreCase))
{
try
{
fb.VerifyGetSubscription(
Request.Params["hub.mode"],
Request.Params["hub.verify_token"],
Request.Params["hub.challenge"]);
Response.Write(Request.Params["hub.challenge"]);
}
catch (Exception ex)
{
Response.Write(ex.StackTrace);
}
}
else
{
//process ipn payments?
//get paymentid from post
try
{
//insert into general log that this page was called
foreach (string key in Request.Form.Keys)
{
owner_functions.CreateGeneralLog("FB RTU Page", "Page was
called:" + Request.Form[key]);
}
//need to find out exactly what data is sent to callback form
var order_details_array = Request.Form["payments"];
if (order_details_array != null)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
Dictionary<string, object> order_details =
jss.Deserialize<Dictionary<string,
object>>(order_details_array);
string payment_id = order_details["id"].ToString();
string apptoken = "apptoken";
string facebook_urlGetPurchase = payment_id + "?access_token=";
dynamic me = fb.Get(facebook_urlGetPurchase + apptoken);
ProcessOrder(me);
}
The final function gets the payment_id # from the graph api and then
awards the item based on that information, etc. All of that is working if
I hard code the GET information. Again, The problem is that I can't seem
to get the POST information when FB hits the callback URL.
What am I missing? Thanks everyone.

No comments:

Post a Comment