使用C#从Facebook获取FB的数据页 [英] Getting FB Page data from facebook using C#

查看:425
本文介绍了使用C#从Facebook获取FB的数据页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的桌面应用程序,我想读的留言板上的帖子,留言,像计数等特定的 Facebook页面 (不适用于Facebook的用户)

In my Desktop application, I want to read the Wall posts,Messages, Like counts etc for a particular Facebook page (not for a facebook user)

我通过这个帖子<一去href=\"http://stackoverflow.com/questions/9973176/getting-my-own-data-from-facebook-using-c-sharp-without-an-application\">get用户数据(#2)。我想达到同样的事情,但对于一个FB页面。

I went through this post get user data(on stackoverflow). I want to achieve the same thing but for a FB page.

我准备创建一个Facebook应用程序,以实现这一目标,并让用户赋予权限拉数据。

I am ready to create a facebook application to achieve this and have the user to give permission to pull the data.

请对上述建议。

推荐答案

您需要一个访问令牌从Facebook获取页面的数据。
使用下面的网址与您的Facebook应用程序的参数首先得到一个访问令牌:

You need an access token to get page data from Facebook. First get an access token using below URL with your facebook application's parameters:

<$c$c>https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={yourappid}&client_secret={yourappscret}

然后就可以调用Facebook的图形API与返回的标记

Then you can call the Facebook Graph API with returning token

常规: https://graph.facebook.com/wikipedia?access_token= {令牌}

文章: https://graph.facebook.com/wikipedia/posts?access_token= {令牌}

这是例如code会;

An example code would be;

class Program
{
    static void Main(string[] args)
    {
        var client = new WebClient();

        string oauthUrl = string.Format("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={0}&client_secret={1}", "appid", "appsecret");

        string accessToken = client.DownloadString(oauthUrl).Split('=')[1];

        string pageInfo = client.DownloadString(string.Format("https://graph.facebook.com/wikipedia?access_token={0} ", accessToken));
        string pagePosts = client.DownloadString(string.Format("https://graph.facebook.com/wikipedia/posts?access_token={0} ", accessToken));
    }
}

这篇关于使用C#从Facebook获取FB的数据页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆