问题描述
我想通过通过我的FB应用在墙壁上张贴他们在Facebook上分享项目。我设置的一切在客户端和服务器端,以及(ASP.NET MVC3),但我注意到,当ActionMethod装饰与 CanvasAuthorize
属性,该方法不没有得到所有触发。那么,有什么我可以做什么?
I am trying to share items on Facebook by posting them on the wall via my FB app. I setup everything on the client side and the server side as well (ASP.NET MVC3), but I noticed that when the ActionMethod is decorated with the CanvasAuthorize
attribute, the method does not get triggered at all. So is there anything I could do?
P.S:我通过AJAX调用检查发布的数据,一切都似乎在为此罚款。此外,如果我评论了 [CanvasAuthorize]
线,该方法被触发,PARAMS无一不精,除非我得到的 fb.Post ()
呼叫时,报告说,没有任何的access_token这是有道理的。
P.S: I checked the posted data by the AJAX call and everything seemed fine on that end. Moreover, if I comment the [CanvasAuthorize]
line, the method gets triggered and the params are all fine, except when I get to the fb.Post()
call, it complains that there is no access_token which makes sense.
//[CanvasAuthorize(Permissions = "publish_stream")]
public ActionResult PostItem(string message, string link, string picture, string name)
{
var fb = new FacebookWebClient();
var postArgs = new Dictionary<string, string>();
postArgs["message"] = message;
postArgs["link"] = link;
postArgs["picture"] = picture;
postArgs["name"] = name;
fb.Post("/me/feed", postArgs);
return Json(new {result = "success"}, JsonRequestBehavior.AllowGet);
}
任何想法?
更新:
下面是后续:Passing用AJAX调用的ActionMethod饰有CanvasAuthorize 沿signed_request
Here's a follow-up: Passing the signed_request along with the AJAX call to an ActionMethod decorated with CanvasAuthorize
推荐答案
使用,你通过你的Ajax调用隐藏字段。
Use a hidden field which you pass with your ajax call.
您可以自己或使用实现这个:
You can implement this by yourself or use:
<%: Html.FacebookSignedRequest() %>
这篇关于AJAX调用不会触发操作方法当装饰用CanvasAuthorize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!