Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# facebook粉丝页面管理员如何发布_C#_Facebook_Post_Admin - Fatal编程技术网

C# facebook粉丝页面管理员如何发布

C# facebook粉丝页面管理员如何发布,c#,facebook,post,admin,C#,Facebook,Post,Admin,**我可以进行安装,但作为facebook的管理员,我自己并不分享。有什么问题吗?Asp.net我正在使用facebook sdk 管理员如何访问风扇页面 protected void Page_Load(object sender, EventArgs e) { if (Request["Code"] == null) { Response.Redirect(string.Format("https://graph.facebook.com/oauth/autho

**我可以进行安装,但作为facebook的管理员,我自己并不分享。有什么问题吗?Asp.net我正在使用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);
}
受保护的无效页面加载(对象发送方,事件参数e)
{
如果(请求[“代码”]==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));
}
}
私有无效检查授权()
{
字典标记=新字典();
字符串url=string.Format(“https://graph.facebook.com/oauth/access_token?client_id={0}&重定向_uri={1}&作用域={2}&代码={3}&客户端_secret={4},app_id,Request.Url.AbsoluteUri,作用域,请求[“code”],app_secret);
HttpWebRequest request=System.Net.WebRequest.Create(url)作为HttpWebRequest;
使用(HttpWebResponse=request.GetResponse()作为HttpWebResponse)
{
StreamReader=新的StreamReader(response.GetResponseStream());
字符串vals=reader.ReadToEnd();
foreach(vals.Split('&')中的字符串标记)
{
Add(token.Substring(0,token.IndexOf(“=”),token.Substring(token.IndexOf(“=”)+1,token.Length-token.IndexOf(“=”)-1));
}
}
字符串访问令牌=令牌[“访问令牌”];
dynamic messagePost=new expandooobject();
messagePost.access\u token=access\u token;
messagePost.picture=“图片”;
messagePost.link=“link”;
messagePost.name=“name”;
messagePost.caption=“caption”;
messagePost.description=“description”;
FacebookClient app=新的FacebookClient(访问令牌);
app.Post(“/PAGE ID/feed”,messagePost);
}

正如文档所说,您需要有特殊的页面标记

  • 应用程序必须对用户具有“管理页面”权限
  • 获取页面令牌(不是您的用户令牌!)

    GEThttps://graph.facebook.com/{page id}?fields=access\u token

  • 您还可以显示当前用户可以管理的所有页面

    GEThttps://graph.facebook.com/v2.8/me/accounts?access_token=#{user_token}

  • 将返回如下内容:

    {
    “数据”:[
    {
    “访问令牌”:“EAACEdEose0cBACZBQs59Xjr…”,
    “类别”:“社区”,
    “名称”:“xxx”,
    “id”:“111”,
    “烫发”:[
    “管理”,
    “编辑您的个人资料”,
    “基本管理”
    ]
    },
    {
    “访问令牌”:“EAACEDEOSE0CBARKAGY…..用于”,
    “类别”:“杂志”,
    “名称”:“xxx”,
    “id”:“111”,
    “烫发”:[
    “创建内容”,
    “中等含量”,
    ]
    },