Get Facebook wall posts from fan page or group
I use the facebook api wrapper from https://github.com/facebook/csharp-sdk, then I have created a facebook application and I use the Access Token from the facebook application but still I can't get the wall posts from a fan page I have created? It seems like I need 开发者_运维知识库to authenticate with a user even though I use the access token?
The user always has to grant you permission to read his wall posts, there's only some basic information publicly available.
If you're just accessing this one fan page, you have the options of using Facebook PowerShell Module, this is
PS C:\Windows\system32> Get-FBAssociation -id 219372234769562 -type Statuses
id : 245067728866679
message : Jonatan Larsson, ägare och grundare till Kundo.se nämner BrickPile i veckans länktips http://lillbra.se/2011/08/veckans-lnktips-2011-08-14/
likes : {@{id=611391282; name=Amanda Lägervik}, @{id=219372234769562; name=BrickPile}}
from : @{id=219372234769562; name=BrickPile; category=Software}
updated_time : 2011-08-21T19:03:12+0000
do you means to retrieve what others people post on your page right? i hope this solution can help you. Firstly ofcourse you needed the access token, then put this code in onclick button:
var fb = new FacebookClient(lblToken.Text);
var query = string.Format(@"SELECT type, target_id, post_id, message, actor_id, tagged_ids
FROM stream WHERE source_id =551183598322481 AND actor_id !=551183598322481");//sourceID & actorID here is your PAGE_ID
dynamic parameters = new ExpandoObject();
parameters.q = query;
dynamic results = fb.Get("/fql", parameters);
List<MyPageStream> q = JsonConvert.DeserializeObject<List<MyPageStream>>(results.data.ToString());
GridView1.DataSource = q;
GridView1.DataBind();
Then outside the onclick button, put this code:
public class MyPageStream
{
public string post_id { get; set; }
public string target_id { get; set; }
public string type { get; set; }
public string message { get; set; }
public string actor_id { get; set; }
//public long tagged_ids { get; set; } permalink
}
精彩评论