使用asp.net中的ImpactWorks.FBGraph在Facebook上发布mvc c#给出错误,远程服务器返回错误:(403)Forbidden

时间:2014-06-03 12:33:25

标签: c# asp.net-mvc facebook-graph-api fb-graph

我在我的Asp.net MVC项目中使用ImpactWorks.FBGraph.dll使用图形API在facebook中实现了POST功能。在最后它调用函数facebook.PostToWall()然后给出错误远程服务器返回错误:(403)Forbidden。

我的代码

public Facebook FacebookAuth()
        {
            //Setting up the facebook object
            Facebook facebook = new ImpactWorks.FBGraph.Connector.Facebook();


            facebook.AppID = "XXXXXXXXXXXXXXX";
            facebook.Secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
            facebook.CallBackURL = "http://localhost/Retail_MVC/Facebook/Success";

            //Setting up the permissions
            List<FBPermissions> permissions = new List<FBPermissions>() {
                FBPermissions.user_about_me, // to read about me               
                FBPermissions.user_events,
                FBPermissions.user_status,
                FBPermissions.read_stream,
                FBPermissions.friends_events,
                FBPermissions.publish_stream,
            };

            //Pass the permissions object to facebook instance
            facebook.Permissions = permissions;
            return facebook;
        }

我的返回URL功能如下所示,之后我使用authLink完成了身份验证功能

public ActionResult Success()
        {
                Facebook facebook = auth.FacebookAuth();
 string Code = Request.QueryString["code"];
                Session["facebookQueryStringValue"] = Code;
                facebook.GetAccessToken(Session["facebookQueryStringValue"].ToString());
                FBUser currentUser = facebook.GetLoggedInUserInfo();
                IFeedPost FBpost = new FeedPost();

                    FBpost.Message = "Hello, whats up"
                    facebook.PostToWall(currentUser.id.GetValueOrDefault(), FBpost);

            return View();
        }

当调用最后一个函数PostToWall()时,它会给出错误 “远程服务器返回错误:(403)禁止。”

请给我适当的解决方案来解决这个问题。

0 个答案:

没有答案