如何可以facebook粉丝页管理帖子
本文关键字:管理 何可 facebook | 更新日期: 2023-09-27 18:13:12
**我可以做安装,但以我自己的名义作为管理员的facebook是发送不共享的。有什么问题吗?我使用的是facebook sdk
管理员如何访问粉丝页面
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Code"] == null)
{
Response.Redirect(string.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope));
}
}
private void CheckAuthorization()
{
Dictionary<string, string> tokens = new Dictionary<string, string>();
string url = string.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request["Code"], app_secret);
HttpWebRequest request = System.Net.WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string vals = reader.ReadToEnd();
foreach (string token in vals.Split('&'))
{
tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1));
}
}
string access_token = tokens["access_token"];
dynamic messagePost = new ExpandoObject();
messagePost.access_token = access_token;
messagePost.picture = "picture";
messagePost.link = "link";
messagePost.name = "name";
messagePost.caption = "caption";
messagePost.description = "description ";
FacebookClient app = new FacebookClient(access_token);
app.Post("/PAGE ID/feed", messagePost);
}
https://developers.facebook.com/docs/pages/getting-started#get_tokenhttps://developers.facebook.com/docs/pages/publishing
正如文档所述,您需要有特殊的页面令牌
- 您的应用程序必须对您的用户具有'manage_pages'权限
-
获取页面令牌(不是您的用户令牌)
GET https://graph.facebook.com/{page-id}?fields=access_token
-
还可以显示当前用户可以管理的所有页面。
GET https://graph.facebook.com/v2.8/me/accounts?access_token=#{user_token}
将返回如下内容:
{
"data": [
{
"access_token": "EAACEdEose0cBACZBQs59Xjr....",
"category": "Community",
"name": "xxx",
"id": "111",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"BASIC_ADMIN"
]
},
{
"access_token": "EAACEdEose0cBAPRKAgY.....FOr",
"category": "Magazine",
"name": "xxx",
"id": "111",
"perms": [
"CREATE_CONTENT",
"MODERATE_CONTENT",
]
},