简体   繁体   中英

Publish Post on facebook wall with any authenticated user using C#

I am using ImpactWorks.FBGraph dll to Post on facebook wall using C#.

I have created App using my xyz@gmail.com id and get AppId and Secret key

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

Its works fine when i loggin with user (xyz@gmail.com) under which i have created App

But when i try to loggin with different facebook account it gives me 403 (Forbidden) error.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM