我正在制作一个测试c#winform程序,用于通过sdk发布到facebook上。 我的代码在下面;我猜它成功了,我得到了最终结果,如{{" id":" 110367383104533_110569899750948"}} 但是当我进入我的脸书时,没有新发布的内容。 没有错误。这种情况有什么不对?
string sAppID = "<MyAppID>";
string sAppSecret = "<MyAppSecretCode>";
string sAccessToken = String.Empty;
string sPageID = String.Empty;
FacebookClient fb = new FacebookClient();
dynamic result = fb.Get("/oauth/access_token", new
{
client_id = sAppID,
client_secret = sAppSecret,
grant_type = "client_credentials",
scope = "manage_pages, publish_pages, publish_stream"
});
sAccessToken = result.access_token;
if (!String.IsNullOrEmpty(sAccessToken))
{
fb = new Facebook.FacebookClient(sAccessToken);
fb.AccessToken = sAccessToken;
fb.AppId = sAppID;
fb.AppSecret = sAppSecret;
dynamic fbAccounts = fb.Get($"/{sAppID}/accounts");
foreach (dynamic account in fbAccounts.data)
{
sPageID = account.id;
sAccessToken = account.access_token;
break;
} //foreach
fb = new FacebookClient(sAccessToken);
dynamic parameters = new ExpandoObject();
parameters.message = tbxMessage.Text;
dynamic dResult = fb.Post($"/{sPageID}/feed", parameters);
MessageBox.Show(dResult.id);
}
else
{
MessageBox.Show("failed to get access token");
return;
} // else