2011-04-17 51 views
1

我试图检索一个特定用户的墙贴,类似的问题已经在这里回答 - How to get posts of user,但由于一些奇怪的原因,它不适合我。访问Facebook用户墙帖子使用C#sdk

我跟着CodePlex上文档中的文章 - Getting Started with an ASP.NET MVC 3 Website

的的AccountController代码类似于https://gist.github.com/899052以下是它试图获取职位

var facebookId = long.Parse(User.Identity.Name); 
var user = this.repository.Get(facebookId); 
var fb = new FacebookWebClient(user.AccessToken); 
dynamic result = fb.Get("me/feed"); 

的操作方法,但我总是得到一个result.data中的空数组。我不太确定,是否需要设置任何权限,如果有,我该怎么做?

更新:

在账户控制器,我并没有要求在登录方法权限,下面是解决问题

public ActionResult LogOn(string returnUrl) 
{ 
    var oAuthClient = new FacebookOAuthClient(FacebookApplication.Current) 
    { 
     RedirectUri = GetOAuthCallbackUri() 
    }; 
    Dictionary<string, object> parameters = new Dictionary<string, object>(); 
    parameters.Add("state", returnUrl); 
    parameters.Add("scope", "offline_access,read_stream,user_photos,user_videos,publish_stream"); 
    var loginUri = oAuthClient.GetLoginUrl(parameters); 
    return Redirect(loginUri.AbsoluteUri); 
} 

在此之前它可以做的方式,我收到了一个在5.0.9 error on Exchange code for access token中提到的错误,但我下载了最新的源代码,编译为该帖子中的回答

回答

2

首先,确保您获得'read_stream'权限的授权,否则你将无法访问新闻提要。

其次,浏览到该路径...

https://graph.facebook.com/[user_id]/feed?access_token=[access_token] 

...你已经收到了访问令牌后,看看你是否得到相同的结果。

+0

你能告诉我如何授权'read_stream'权限 – Rajeesh 2011-04-18 06:07:35

+0

@Sambo ..你指出我正确的方向。我已经为问题本身添加了**更新**,它显示我已完成的代码修复 – Rajeesh 2011-04-18 19:18:26

相关问题