使用c#与任何经过身份验证的用户在facebook墙上发布帖子

本文关键字:facebook 布帖 用户 任何 经过 身份验证 使用 | 更新日期: 2023-09-27 18:06:44

我使用的是ImpactWorks。使用c#将FBGraph dll发布到facebook墙上。

我已经创建了应用程序使用我的xyz@gmail.com id和获得AppId和秘密关键

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

它的工作很好,当我登录用户(xyz@gmail.com)下,我创建App

但是当我尝试用不同的facebook帐户登录时,它给了我403 (Forbidden)错误。

使用c#与任何经过身份验证的用户在facebook墙上发布帖子

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);
}