c# - Insufficient permission to post to target on behalf of the viewer -
i have 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) httpwebrequest; using (httpwebresponse response = request.getresponse() 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 caption!"; args["description"] = "this description!"; args["name"] = "this name!"; args["picture"] = "picutre"; args["link"] = "http://www.bradspel.net/"; client.post("/1418771281723422/feed", args); } }
when posting :
(oauthexception - #200) (#200) insufficient permission post target on behalf of viewer
if change client.post :
client.post("/me/feed", args);
it works fine.
so why not working when im post specific wall? have set permission on facebook page let post. facebook app set online.
by creating extended page token , use make post works fine. see : how page access token code?
im surprised simple task hard running , there vary little get.
Comments
Post a Comment