开发者

AJAX Call Does Not Trigger Action Method When Decorated With CanvasAuthorize

I am trying to share items on Facebook by po开发者_JAVA百科sting 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: 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);
    }

Any ideas?

UPDATE:

Here's a follow-up: Passing the signed_request along with the AJAX call to an ActionMethod decorated with CanvasAuthorize


Use a hidden field which you pass with your ajax call.

You can implement this by yourself or use:

<%: Html.FacebookSignedRequest() %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜