使用C#在任何经过​​身份验证的用户的Facebook墙上发布帖子

时间:2014-06-05 06:32:22

标签: c# facebook facebook-graph-api

我使用ImpactWorks.FBGraph dll在Facebook墙上使用C#发布。

我使用我的xyz@gmail.com id创建了App并获得了AppId和Secret  键

facebook.AppID = "51312xxxxxxxxx";
facebook.Secret = "66e76e49be4e92390fxxxxxxxxx";

当我使用用户(xyz@gmail.com)登录时,它的工作正常  创建了应用程序

但是当我尝试使用不同的Facebook帐户登录时,它会给我  403(禁止)错误。

1 个答案:

答案 0 :(得分:0)

Get Solution using aspsnippets.facebookapi.dll. 

protected void Page_Load(object sender, EventArgs e)
{
    FaceBookConnect.API_Key = "<Your API KEY>";
    FaceBookConnect.API_Secret = "<Your API SECRET>";

    if (!IsPostBack)
    {
        string code = Request.QueryString["code"];
        if (!string.IsNullOrEmpty(code))
        {
            ViewState["Code"] = code;
            pnlPost.Enabled = true;
            btnAuthorize.Enabled = false;
        }
    }
}

protected void Authorize(object sender, EventArgs e)
{
    FaceBookConnect.Authorize("publish_actions", Request.Url.AbsoluteUri);
}

protected void Post(object sender, EventArgs e)
{
    Dictionary<string, string> data = new Dictionary<string, string>();
    data.Add("link", "http://www.aspsnippets.com");
    data.Add("picture", "http://www.aspsnippets.com/images/Blue/Logo.png");
    data.Add("caption", "ASP Snippets");
    data.Add("name", "ASP Snippets");
    data.Add("message", "I like ASP Snippets");
    FaceBookConnect.Post(ViewState["Code"].ToString(), "me/feed", data);
}