UPDATE 从那以后我就能够让popup工作了。我删除/注释了我在下面使用的不必要的代码。出于某些奇怪的原因,我不得不从我的ashx切换到aspx。只需确保您在数据库中查找的所有变量都存在:)
我在Facebook应用程序中实现Facebook信用有一些问题。我正在使用Facebook C# SDK,我确信我的javascript是犹太洁食。我发现this博客很有用,但我在javascript回调中从Facebook收到了AppInvalidDecodedResponse错误。我最初试图让'买'弹出窗口显示出来。这是我在应用程序设置中指定的ashx回调:
public void Page_Load(object sender, EventArgs e)
{
string order_id = Request.Form["order_id"];
string method = Request.Form["method"];
string order_info = Request.Form["order_info"];
FacebookBuyItem theItem = new FacebookBuyItem();
theItem.title = "item not found";
theItem.price = "1";
theItem.image_url = Utilities.GlobalSettings["WebDomain"];
theItem.product_url = Utilities.GlobalSettings["WebDomain"];
theItem.description = "item not found";
if (method == "payments_get_items")
{
//order_info = (string)data["order_info"];
//order_info = order_info.Substring(1, (order_info.Length - 2));
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = new SqlConnection(Utilities.PluginSettings["SQL Database"]["ConnectionString"]);
cmd.Connection.Open();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "dbo.GetItem";
cmd.Parameters.Add("@ItemID", System.Data.SqlDbType.Int).Value = int.Parse(order_info);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
theItem.title = dr["ItemName"].ToString();
theItem.price = dr["FacebookCreditCost"].ToString();
theItem.image_url = dr["ThumbPath"].ToString();
theItem.product_url = dr["ThumbPath"].ToString();
theItem.description = dr["Description"].ToString();
}
dr.Close();
cmd.Connection.Close();
}
}
//Utilities.Dump(order_info, order_id, method);
var res = new Dictionary<string, object>();
res["method"] = method;
//res["order_id"] = order_id;
res["content"] = new object[] { theItem };
JavaScriptSerializer jss = new JavaScriptSerializer();
string ob = jss.Serialize(res);
//ob = ob.Replace("#$", @"\/");
Response.ContentType = "application/json";
Response.Write(ob);
Response.End();
}
答案 0 :(得分:1)
我是Facebook的工程师,希望能在这里提供帮助。无效的解码响应意味着回调未在payments_get_items
调用期间向facebook提供必要且格式正确的项目信息。好消息是,facebook正在从你的回调中获取某些东西,而不是正确的某些东西。我对c#没有经验,但首先,我会尝试编写你的项目名称,价格等,就像我在下面所做的那样,并检查它是否按预期工作。
theItem.title = 'BFF Locket';
theItem.price = 1;
theItem.image_url = 'http://www.facebook.com/images/gifts/21.png';
theItem.product_url = 'http://www.facebook.com/images/gifts/21.png';
theItem.description = 'This is a BFF Locket...';
如果您仍有问题,请告诉我,我可以进一步研究。