我正在开发使用Facebook C#SDK在Facebook上管理粉丝页面的C#应用程序.我遇到了两个问题,一个是关于在墙上发布消息,另一个是关于在粉丝页面上创建事件.
是否可以在粉丝页面墙上发布消息作为粉丝页面而不是管理员用户?
我可以使用Facebook C#SDK以编程方式在粉丝页面上创建活动(不是作为管理员,而是作为粉丝页面)吗?
我浏览了其他SDK的其他一些教程,比如Facebook PHP SDK.PHP SDK允许将事件创建为粉丝页面,但在C#SDK的情况下,创建事件不会产生任何结果.
好的,我刚刚遇到了同样的事情.为了我的目的,我正在授权一个应用程序发布到FB粉丝页面作为粉丝页面.因此,我可以让多个用户访问该应用程序,但不能访问粉丝页面,将其作为粉丝页面发布.它适用于我的要求.
无论如何,这是我使用C#Facebook SDK Beta V5.0.9的方式.第一步,确保您尝试发布的用户帐户能够发布到粉丝页面,并且有权通过应用程序进行操作.
其中大部分与VorTechS相似,只是对其进行了一些澄清.
Dictionary<string,string> fbParams = new Dictionary<string,string>();
fbParams["message"] = Title;
fbParams["caption"] = string.Empty;
fbParams["description"] = string.Empty;
fbParams["req_perms"] = "publish_stream";
fbParams["scope"] = "publish_stream";
//Initialize Your Facebook Client in the manner that suits you, I did it by supplying a saved access token from a single users
FacebookWebClient fbClient = new FacebookWebClient(<YOUR_ACCOUNT_ACCESS_TOKEN>);
//Get the listing of accounts associated with the user
dynamic fbAccounts = fbClient.Get("/me/accounts");
//Loop over the accounts looking for the ID that matches your destination ID (Fan Page ID)
foreach (dynamic account in fbAccounts.data) {
if (account.id == <DESTINATION_ID_OF_YOUR_FAN_PAGE>) {
//When you find it, grab the associated access token and put it in the Dictionary to pass in the FB Post, then break out.
fbParams["access_token"] = account.access_token;
break;
}
}
//Then pass your destination ID and target along with FB Post info. You're Done.
dynamic publishedResponse = fbClient.Post("/" + <DESTINATION_ID_OF_YOUR_FAN_PAGE> + "/feed", fbParams);
Run Code Online (Sandbox Code Playgroud)