简体   繁体   English

C#Facebook SDK - 用户墙上发布的服务器

[英]C# Facebook SDK - server to post on user wall

using facebook sdk v 6 for .net i want my server to create a post to a user wall using facebook app 使用facebook sdk v 6 for .net我希望我的服务器使用facebook app为用户墙创建帖子

My code: 我的代码:

    var client = new FacebookClient();
    dynamic result = client.Get("oauth/access_token", new { 
        client_id = appId,
        client_secret = appSecret,
        grant_type = "client_credentials"
    });

    client.AccessToken = result.access_token;

    var args = new Dictionary<string, object>();
    args["message"] = "abc";
    args["caption"] = "This is caption!";
    args["description"] = "This is description!";
    args["name"] = "This is name!";

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

app configuration: extended permissions : publish_stream , read_stream , export_stream, status_update ,share_item user permissions : user_about_me, publish_actions visible to all users sandbox mode : disabled appdomains : localhost Website with Facebook Login - site url:localhost:8085 应用程序配置:扩展权限:publish_stream,read_stream,export_stream,status_update,share_item用户权限:user_about_me,对所有用户可见的publish_actions沙箱模式:已禁用appdomains:localhost有Facebook登录的网站 - site url:localhost:8085

this 'user' im trying to publish on his wall is a TEST user in my app. 这个'用户'我试图在他的墙上发布是我的应用程序中的TEST用户。 now, when i get to client.Post("user/feed", args); 现在,当我到达client.Post("user/feed", args); it throws this exception: 它抛出此异常:

(OAuthException - #200) (#200) The user hasn't authorized the application to perform this action (OAuthException - #200)(#200)用户尚未授权应用程序执行此操作

solution ? 解决方案

you are using app's token to post on user's wall - that's not allowed. 您正在使用应用程序的令牌在用户的墙上发布 - 这是不允许的。 Your USER should give permissions to your app - and in return you will get USER token - and you should use it in API calls. 您的用户应该为您的应用授予权限 - 作为回报,您将获得USER令牌 - 您应该在API调用中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM