在一天的大部分时间里,我一直在尝试在我的应用程序的时间线/提要/Fb 墙上发布一些内容,但我一直失败。这越来越令人沮丧。
我正在做的是:我有一个简单的控制台 C# 应用程序,它试图在应用程序的墙上发布一些东西(例如,一个基本的 hello world!)。
此片段显示了我如何检索访问令牌:
private string _AccessToken;
public string AccessToken
{
get
{
if (string.IsNullOrEmpty(_AccessToken))
{
//_AccessToken = string.Format("{0}|{1}", Credentials.AppId, Credentials.AppSecret);
Logger.Debug("Attempting to retrieve the access token...");
dynamic result = ExecuteGet("oauth/access_token", new
{
client_id = Credentials.AppId, // my app id
client_secret = Credentials.AppSecret, // my app secret
grant_type = "client_credentials",
scope = "manage_pages,publish_actions,publish_stream"
}, false);
_AccessToken = result.access_token;
}
Logger.Debug("Operation succeeded, access token is : {0}", _AccessToken);
return _AccessToken;
}
}
private object ExecuteGet(string path, object parameters)
{
return ExecuteGet(path, parameters, true);
}
private object ExecuteGet(string path, object parameters, bool useAccessToken)
{
try
{
Logger.Debug("Executing GET : {0}", path);
var client = useAccessToken ? new FacebookClient(AccessToken) : new FacebookClient();
return client.Get(path, parameters);
}
catch (FacebookApiException ex)
{
Logger.Error("GET Operation failed : {0}", ex.Message);
throw;
}
}
这就是我试图实际发布内容的方式:
public void PostToApplicationWall(string message)
{
string path = string.Format("/{0}/feed", Credentials.AppId);
IDictionary<string, object> parameters = new Dictionary<string, object>()
{
{ "description", "[DESCRIPTION] Facebook description..." },
{ "link", "http://tinyurl.org" },
{ "name", "[NAME] Facebook name..." },
{ "caption", "[CAPTION] Facebook caption..." },
{ "message", message }
};
dynamic result = ExecutePost(path, parameters);
}
private object ExecutePost(string path, object parameters)
{
try
{
Logger.Debug("Executing POST : {0}", path);
var client = new FacebookClient(AccessToken);
return client.Post(path, parameters);
}
catch (FacebookApiException ex)
{
Logger.Error("POST Operation failed : {0}", ex.Message);
throw;
}
}
请注意 ExecutePost() 使用 AccessToken 属性,我已经粘贴在开头。
我收到的消息是:(OAuthException - #210) (#210) Subject must be a page
请帮忙,我不知道我做错了什么。