c# - 通过应用程序发布指向粉丝页面的链接

标签 c# asp.net facebook facebook-graph-api

我们有一个定制的 CMS,用户可以选择在发布消息时将其发布到公司的“粉丝页面”。此代码使用 Facebook 提供的 FacebookAPI 代码在 C# 应用程序(实际上是 WCF web 服务)中使用 Graph API。

我们之前发帖时遇到过各种问题(参见 this bugthis discussion )。这已经工作了一段时间,但现在返回 400/Bad Request。

我尝试了两种不同的(之前已知有效的)api token 。此设置几个月来没有更改代码。

我想知道如何弄清楚为什么它现在不再发布。它请求的 token 有什么变化吗?

这是我使用的代码:

FacebookAPI api = new FacebookAPI(token);

Dictionary<string, string> postArgs = new Dictionary<string, string>();

postArgs["link"] = url;
postArgs["message"] = message;

try
{
    JSONObject jsonresult = api.Post("me/links", postArgs);
    result = "ok";
}
catch (Exception e)
{
    result = "Post Failed - " + e.Message.ToString();
}

我的异常是 400/Bad Request

更新:我还注意到根据 Authentication Docs ,现在有些 token 已经过期,而我的似乎没有。这可能是个问题吗?例如,我的 token 是一个 ~100 字符的字符串,由 3 个管道 (|) 分隔的 4 个部分。然后他们的例子有一个额外的 &expires_in=64090。

最佳答案

现在为了发布链接或状态,您需要用户 access_token 和链接权限。确保用户已为执行链接发布的应用程序提供 publish_stream 权限。此外,消息参数应该在发布时被忽略,但我不会预先填充它只是为了避免错误。

You can post a link on the user's behalf by issuing an HTTP POST request to PROFILE_ID/feed with the publish_stream permissions and the following parameters.

http://developers.facebook.com/docs/reference/api/user/#links

我用来发帖的 javascript 示例。

window.feedthis = function(shf,point,clk) {
     ptsT=point-shf+clk;
             FB.ui({ method: 'feed', 
           // message: 'Testing Feed',
            caption: 'I survived '+shf+' Levels in Another Grid. I earned '+point+' points with '+clk+' clicks.',
            name: 'Another Grid',
            link: 'http://apps.facebook.com/anothergrid/?ref=link',
            //to: '391793380398',
            description: 'Another Grid, A color elemination Puzzle game by Shawn E Carter.',
            picture: 'https://shawnsspace.com/ShawnsSpace.toon.nocolor..png',
            properties: [{ text: 'Play the Game', href: 'http://apps.facebook.com/anothergrid/?ref=achievement'}
                            //{ text: 'ShawnsSpace', href: 'http://apps.facebook.com/shawnsspace/?ref=anothergrid'}
                            ],
            actions: [
            { name: 'Another Grid', link: 'http://apps.facebook.com/anothergrid/'}
            ]       
            });
            };

关于c# - 通过应用程序发布指向粉丝页面的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7270992/

相关文章:

c# - Java 和 C# 的并行开发

c# - ReSharper:如何使用另一个属性隐式应用 [NotNull] 或 [CanBeNull] 注释?

javascript - 使用 Javascript 在单击时隐藏 ImageButton

iphone - 从 iOS 应用程序发布时出现 Facebook SDK 3.1 错误

c# - 泛型方法之间的模糊引用

asp.net - Umbraco - 获取配置文件目录

c# - MailChimp Api 3.0 兴趣小组

ios - 无连接时返回 SLComposeViewControllerResultDone

IOS SWIFT : You have already authorized facebook ios

c# - 我数据库中的所有数据都是更新的。如何只更新 1 行?