Insufficient sending permission for the target audience on behalf of the viewer

I have the following code:

private void CheckAuthorization() { string app_id = "x"; string app_secret = "x"; string scope = "publish_stream,publish_actions"; if (Request["code"] == null) { Response.Redirect(string.Format( "https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope)); } else { Dictionary<string, string> tokens = new Dictionary<string, string>(); string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request["code"].ToString(), app_secret); HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { StreamReader reader = new StreamReader(response.GetResponseStream()); string vals = reader.ReadToEnd(); foreach (string token in vals.Split('&')) { //meh.aspx?token1=steve&token2=jake&... tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1)); } } string access_token = tokens["access_token"]; var client = new FacebookClient(access_token); //client.Post("/me/feed", new { message = "A simple test" }); var args = new Dictionary<string, object>(); args["message"] = "abc"; args["caption"] = "This is caption!"; args["description"] = "This is description!"; args["name"] = "This is name!"; args["picture"] = "picutre"; args["link"] = "http://www.bradspel.net/"; client.Post("/1418771281723422/feed", args); } } 

When publishing, I get the following:

(OAuthException - # 200) (# 200) Insufficient permission to publish to the target on behalf of the viewer

If I change client.post to this:

 client.Post("/me/feed", args); 

It works great.

So why doesnโ€™t it work when I am going to post a specific wall? I set permission on this facebook page so that everyone can post messages. The facebook application is installed online.

+5
source share
2 answers

By creating an extended page token and using it to make a message, everything works fine. See This: How to get a page access token by code?

I was surprised that this simple task was so difficult for work, and that help did not work out.

+7
source

When posting to a page (as opposed to your own wall), our testing shows that you donโ€™t necessarily like the brand page to publish it, but you will have to publish it with the permission to view โ€œFriendsโ€ or better (for example, Public) to avoid this exceptions. Yes, you will need your users to publish publish_actions.

0
source

Source: https://habr.com/ru/post/1200578/


All Articles