Post On Facebook Page As Page Not As Admin User Using Facebook C# SDK

后端 未结 4 821
北海茫月
北海茫月 2021-01-01 04:10

I\'m developing C# application which manages fan page on Facebook which uses Facebook C# SDK. I\'ve encountered two problems one is connected with posting messages on wall a

4条回答
  •  迷失自我
    2021-01-01 04:48

    Ok, I just ran into this exact same thing. For my purposes, I'm authorizing an application to post to a FB fan page as the fan page. So I can have multiple users that have access to the application, but not access to the Fan Page, posting as the Fan Page. It works for my requirements.

    Anyhow, here is how I did it using the C# Facebook SDK Beta V5.0.9. First Step, make sure the user account you are attempting to post with has the ability to post to the fan page and is authorized to do so from an app.

    The majority of this is similar to VorTechS post, just a bit more clarification on it.

    Dictionary fbParams = new Dictionary();
                    fbParams["message"] = Title;
                    fbParams["caption"] = string.Empty;
                    fbParams["description"] = string.Empty;
                    fbParams["req_perms"] = "publish_stream";
                    fbParams["scope"] = "publish_stream";
                    //Initialize Your Facebook Client in the manner that suits you, I did it by supplying a saved access token from a single users
                    FacebookWebClient fbClient = new FacebookWebClient();
                    //Get the listing of accounts associated with the user
                    dynamic fbAccounts = fbClient.Get("/me/accounts");
    
                    //Loop over the accounts looking for the ID that matches your destination ID (Fan Page ID)
                    foreach (dynamic account in fbAccounts.data) {
                        if (account.id == ) {
                            //When you find it, grab the associated access token and put it in the Dictionary to pass in the FB Post, then break out.
                            fbParams["access_token"] = account.access_token;
                            break;
                        }
                    }
                    //Then pass your destination ID and target along with FB Post info. You're Done.
                    dynamic publishedResponse = fbClient.Post("/" +  + "/feed", fbParams);
    

提交回复
热议问题