简体   繁体   中英

How to post to a facebook fan page's wall with C#!

I have a fan page on my Facebook account.

While posting of regular updates to that page's wall from my asp web application. It always goes to my personal Facebook account not to my fan page.

So how I can make it access my fan page only and post on it?

Here is my simple code ...

    protected void Page_Load(object sender, EventArgs e)
{
    FaceBookConnect.API_Key = ConfigurationManager.AppSettings["FBAPIKey"];
    FaceBookConnect.API_Secret = ConfigurationManager.AppSettings["FBAPISecret"];

    if (!IsPostBack)
    {
        string code = Request.QueryString["code"];
        if (!string.IsNullOrEmpty(code))
        {
            Dictionary<string, string> data = new Dictionary<string, string>();
            data.Add("link", "string here");
            data.Add("picture", "string here");
            data.Add("caption", "string here");
            data.Add("name", "string here");
            data.Add("message", "string here");
            FaceBookConnect.Post(code, "me/feed", data);
        }
    }
}

protected void btnPost_Click(object sender, EventArgs e)
{
    FaceBookConnect.Authorize("publish_actions", ConfigurationManager.AppSettings["FBRedirectURL"]);
}

You need to acquire a page access token first, and then use that to make the post.

https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens

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