移动 Web 应用程序中的 Facebook Credits 回调
我正在尝试使用 asp.net 和 MVC3 创建 Facebook 移动应用程序,并将 Facebook Credits 集成为支付方式。首先,考虑到最近的公告,现在是否可以有一个接受 Facebook Credits 的移动网络应用程序?
如果是这样,我采用了以下帖子中提供的示例
http://www.m-webs .com/blog_facebookcredits.html
并实现了以下控制器操作:
public JsonResult CallBack()
{
string fborder_info = Request.Form["order_info"];
string fborder_id = Request.Form["order_id"];
string fbmethod = Request.Form["method"];
if (fbmethod == "payments_get_items")
{
fborder_info = fborder_info.Substring(1, (fborder_info.Length - 2)); // remove the quotes
ulong credscost = 2; // Price of purchase in facebook credits
var theItem = new FacebookBuyItem()
{
item_id = 123456789,
description = "Own yours today!",
price = credscost,
title = "Digital Unicorn",
product_url = "http://www.facebook.com/images/gifts/21.png",
image_url = "http://www.facebook.com/images/gifts/21.png"
};
var res = new Dictionary<string, object>();
res["method"] = fbmethod;
res["order_id"] = fborder_id;
res["content"] = new object[] { theItem };
var jss = new JavaScriptSerializer();
var ob = jss.Serialize(res);
ob = ob.Replace("#$", @"\/".Replace("//", @"\/"));
return Json(ob, JsonRequestBehavior.AllowGet);
}
return null;
}
我已经验证了 facebook 正在请求回调,并且我还捕获了发回的响应,该响应似乎包含所有必需的内容显示购买对话框的信息,但是我仍然收到以下错误消息:
API 错误代码:1151 API 错误描述:抱歉,此应用程序可能没有资格接受 Facebook 积分。如果此应用程序之前已接受积分,请重试。 错误消息:无效的应用程序
并且从移动浏览器进行测试时:
抱歉,我们在处理您的付款时遇到问题。您尚未为此交易付费。请再试一次。
我还注意到我的回调被请求两次,这似乎也不正确。
任何有关如何启动和运行我的集成的见解将不胜感激。我的 Facebook AppId 是 177876855621874
谢谢。
I'm trying to create a Facebook Mobile Application using asp.net and MVC3 and integrate Facebook Credits as a payment method. First of all, taking the recent annoucements into consideration, is it now possible to have a mobile web application that accepts Facebook Credits?
If so, I've taken the example provided in the following post
http://www.m-webs.com/blog_facebookcredits.html
And implemented the following Controller action:
public JsonResult CallBack()
{
string fborder_info = Request.Form["order_info"];
string fborder_id = Request.Form["order_id"];
string fbmethod = Request.Form["method"];
if (fbmethod == "payments_get_items")
{
fborder_info = fborder_info.Substring(1, (fborder_info.Length - 2)); // remove the quotes
ulong credscost = 2; // Price of purchase in facebook credits
var theItem = new FacebookBuyItem()
{
item_id = 123456789,
description = "Own yours today!",
price = credscost,
title = "Digital Unicorn",
product_url = "http://www.facebook.com/images/gifts/21.png",
image_url = "http://www.facebook.com/images/gifts/21.png"
};
var res = new Dictionary<string, object>();
res["method"] = fbmethod;
res["order_id"] = fborder_id;
res["content"] = new object[] { theItem };
var jss = new JavaScriptSerializer();
var ob = jss.Serialize(res);
ob = ob.Replace("#$", @"\/".Replace("//", @"\/"));
return Json(ob, JsonRequestBehavior.AllowGet);
}
return null;
}
I've verified that the callback is being requested by facebook, and I've also captured the response being sent back, which appears to contain all of the required information to display the purchase dialog, but I'm still getting the following error message:
API Error Code: 1151
API Error Description: Sorry, but this app may not be eligible to accept Facebook Credits. If this app has accepted credits before, please try again.
Error Message: Invalid Application
and when tested from a mobile browser:
Sorry, but we're having trouble processing your payment. You have not been charged for this transaction. Please try again.
I've also noticed that my callback is being requested twice which doesn't seem right either.
Any insight into how to get my integration up and running would be greatly appreciated. My Facebook AppId is 177876855621874
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新:所以我尝试了给出的示例并恢复到网络表单,以测试 给出的示例http://www.m-webs.com/blog_facebookcredits.html。为了让这个解决方案在asp.net MVC3应用程序中工作,我必须将操作类型更改为HttpResponse而不是JsonResult,这是有意义的,因为JsonResult将元素排除在外通常会包含在 HttpResponse 中。
所以控制器操作最终看起来像这样:
我希望这可以帮助任何为 Facebook Credits 实施 MVC3 的人。
Update: So I played around with the examples given and reverted back to webforms in order to test the example given at http://www.m-webs.com/blog_facebookcredits.html. In order to get this solution working in an asp.net MVC3 application I had to change the action type to HttpResponse instead of JsonResult which makes sense as the JsonResult leaves elements out that would normally be included in a HttpResponse.
So the Controller Action ended up looking like this:
I hope this helps out anyone doing an MVC3 implementation for Facebook Credits.