FacebookSharp
FacebookSharp copied to clipboard
Messages from a wall!
How can i get the the messages on the wall of a user?
var fb = new Facebook("access_token");
var feeds = fb.GetFeeds("me",null); var posts = fb.GetPosts("me",null);
make sure u add "using Facebook.Extensions;" too
Thank you for the response! Now i'm having a several problems:
-
I'm trying to access the messages on the wall one by one, like this PostCollection posts = fb.GetPosts("me", null); foreach (Post p in posts){} but the foreach give me an error: "foreach statement cannot operate on variables of type 'FacebookSharp.Schemas.Graph.PostCollection' because 'FacebookSharp.Schemas.Graph.PostCollection' does not contain a public definition for 'GetEnumerator'" How can i solve this?
-
How can i get a connection with facebook without an experation time?
-
How do I force the user to enter his email and password every time he tries to connect to facebook?
try
foreach(var p in posts.Data){
}
and incase you haven't been aware the mergin of FacebookSharp with Facebook C# SDK, I strongly recommend you to read "The State of .Net Facebook Development" - http://ntotten.com/2010/11/the-state-of-net-facebook-development/
and i you want to get without expiration time, make sure you pass the extended permissions as "offline_access"
What is the string id?
extended permissions is specified in readme.md file. https://github.com/prabirshrestha/FacebookSharp/blob/master/README.md
here is an extract from it.
You can specify extened permissions by specifying it in the FacebookSettings.
fbSettings.DefaultApplicationPermissions = new[] { "publish_stream","create_event" } }; Please refer to http://developers.facebook.com/docs/authentication/permissions for more information on extended permissions.
In your case you will need to pass "offline_access" also. The DefaultApplicationPermissions must be during authorization process (getting the access token).
Thank you for the quick response it help me a lot :) Now another thing what is the string id? on the fb.GetFeeds("me",null); ?
there are 3 types of id's in facebook.
- "12345"
- "12345_6789"
- "me"
me is a special type of id, which represents the user/page who is using the access token.
with the given senario: Username id access_token A 1 a5 B 2 b6
when i call var fb = new Facebook("a5"); "me" would refer to 1
but if i do new Facebook("b6"); "me" would refer to 2.
"me" is a special id which represents the user/page with the access token u specified.
var fb = new Facebook("a5"); fb.GetFeeds("me",null);
means get the feeds for the user/page whose access_token is a5.
all are mentioned on facebook documentations. its explained in more deatils there.
I want to get al the names of l the posts on the user wall :
FacebookSharp.Facebook fb = new FacebookSharp.Facebook(facebookAccessToken);
PostCollection posts = fb.GetPosts("me", null);
foreach (var p in posts.Data)
{
Console.WriteLine(p.Name);
}
but the cont on the foreach wallways conts 0. How can i resolve this?
Thank You. I just resolve the problem. But i realise that is not what i realy want. I want to get all the the information like in the user 'Home' tab. It is possible?