Post to application wall as application not as user

时间秒杀一切 提交于 2019-12-03 00:50:28

You will need to make the request using facebook application access token.

var fb = new FacebookClient("{app_access_token}");
dynamic result = fb.Post("/{app_id}/feed", new Dictionary<string, object> { { "message", "hello" } });

There are two ways you can use the application token.

  1. Using FacebookOAuthClient: (This method gets the application access token using the OAuth2 standards which is the preferable way to get the app access token. but makes a request to the facebook server.)

    var fb = new FacebookOAuthClient { ClientId = "{app_id}", ClientSecret = "{app_secret}" };
    dynamic result = fb.GetApplicationAccessToken();
    var appAccessToken = result.access_token;
    
  2. Manually creating the application token:

    var appAccessToken = "{app_id}|{app_secret}";
    

Replace {app_id} and {app_secret} with appropriate values.

As prabir suggested you need to use a facebook client authenticated as the application and not the connected user.

Here is a short code snipet using version 5.03 beta:

var fbApp = new FacebookClient(FacebookContext.Current);
dynamic result = fbApp.Post("/"+FacebookContext.Current.AppId+"/feed", new Dictionary<string, object> { { "message", "Hello World" } });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!