简体   繁体   English

仍然没有解决方案如何简单地发布Facebook墙

[英]Still no solution how to simple post a Facebook wall

I need to post a message from my personal website to the website´s facebook wall page. 我需要将个人网站上的消息发布到网站的Facebook墙上页面。 I dont want the user to authenticate against facebook , instead a default website account should be used(probably the facebook app). 我不希望用户通过facebook进行身份验证 ,而是应使用默认的网站帐户(可能是facebook应用程序)。

This is what I have : 这就是我所拥有的:

  1. Created facebook App at https://developers.facebook.com https://developers.facebook.com创建了Facebook应用
  2. Add Facebook.dll to my ASP.NET webform site(the personal site) Facebook.dll添加到我的ASP.NET Webform网站(个人网站)
  3. Included the following code : 包含以下代码:

    FacebookClient client = new FacebookClient(); FacebookClient客户端=新的FacebookClient();

     result = client.Get("oauth/access_token", new { client_id = ConfigurationManager.AppSettings["FacebookAppId"], client_secret = ConfigurationManager.AppSettings["FacebookAppSecret"], grant_type = "client_credentials" }); client.AccessToken = result.access_token; result = client.Post("1418771281723422/feed", new { message = "Test Message from app" }); result = client.Get("1418771281723422"); 

This returns the following exception on client.Post 这将在client.Post上返回以下异常。

A first chance exception of type 'Facebook.FacebookOAuthException' occurred in Facebook.dll 类型“ Facebook.FacebookOAuthException”的第一次机会异常发生在Facebook.dll中

Additional information: (OAuthException - #200) (#200) The user hasn't authorized the application to perform this action 附加信息:(OAuthException-#200)(#200)用户未授权应用程序执行此操作

What am I doing wrong and why is it so hard to do this simple task? 我在做什么错,为什么要做这么简单的任务如此困难?

Of course you need to authorize a User to post on Facebook - else it would be incredibly easy to create a spam App. 当然,您需要授权用户在Facebook上发布-否则创建垃圾邮件应用程序将非常容易。

What you need is a Page Access Token, take a look at the Facebook docs about the different Tokens and how to get them: https://developers.facebook.com/docs/facebook-login/access-tokens 您需要的是页面访问令牌,看看有关不同令牌的Facebook文档以及如何获取它们: https : //developers.facebook.com/docs/facebook-login/access-tokens

More information about Access Tokens: http://www.devils-heaven.com/facebook-access-tokens/ 有关访问令牌的更多信息: http : //www.devils-heaven.com/facebook-access-tokens/

The code is in PHP, but the text is valid for every language anyway. 该代码使用PHP,但是文本对于每种语言均有效。

This is how to generate an Extended Page Token with PHP: http://www.devils-heaven.com/extended-page-access-tokens-curl/ 这是使用PHP生成扩展页面令牌的方法: http : //www.devils-heaven.com/extended-page-access-tokens-curl/

An Extended Page Token may be exactly what you need, it is valid forever and you can post "as Page" with it. 扩展页面令牌可能正是您所需要的,它永远有效,您可以将其作为“页面”发布。

Doing this with ASP.NET should be pretty similar, but you don´t really need that Facebook SDK if you take a look at the tutorial for extending a Page Token with CURL. 使用ASP.NET进行此操作应该非常相似,但是如果您看一下使用CURL扩展页面令牌的教程,则实际上并不需要Facebook SDK。 This question may help you: curl Request with ASP.NET 这个问题可能会对您有所帮助: 使用ASP.NET卷曲请求

To create an Extended Page Token only for yourself, i suggest creating it without any coding: 要仅为您自己创建扩展页面令牌,我建议您无需任何编码即可创建它:

It´s explained in this article: http://www.devils-heaven.com/facebook-access-tokens/ 本文对此进行了解释: http : //www.devils-heaven.com/facebook-access-tokens/

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

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