Jonh Transnick
Jonh Transnick

Reputation: 31

Post comment on a status Facebook C# API

I'm trying to post a comment to a status on Facebook. Basically what I'm doing is something like this:

var parameters = new Dictionary<string, object>(); parameters["message"] = "hello";
        fb.Post("/"+id+"/comments", parameters);

Where fb is a FacebookClient object and id is the id of the status.

Unfortunately this doesn't post the comment on recent status. For instance, if I type https://graph.facebook.com/"id"/comments in a web-browser it returns no data if the status is recent, but if the status is old (more than 1 month) it returns the information about the comments on that status.

Is there a way to comment on a status, picture, etc. using this API with C#?

Upvotes: 3

Views: 3613

Answers (4)

swati roy
swati roy

Reputation: 1

For this, you need to learn about how can you use Graph API and you also need to learn about some parameters like

  1. height should be in integers which indicated the height of the pixels.
  2. redirection should be in boolean and its default value should be true.
  3. width is in integers which indicates the width of pictures in pixels.

There are many more but it can be understood by the standard programmatic interfaces. When you use the programming language which you prefer should be based on HTTPS requests. The version of APIs describes that all the requests are firstly in encrypted form and then they are sent via HTTPs requests. To do so, you need to send make a registration for your application even users are not allowed to log in. I hope it would work for you. But apart from it, you need to do more researches.

http://wholestatus.com/

Upvotes: 0

Nilesh Patil
Nilesh Patil

Reputation: 9

I was having the same issue so I tried few things & this worked for me

var token = "[your access token]";
var fb = new Facebook.FacebookClient(token);

var postId = "173213306032925_74xxxxxxxxxxxxx"; //replace this with your big id which comprises of [userid]_[postid]
var parameters = new Dictionary<string, object>();
parameters.Add("message", "test message");
Console.WriteLine(fb.Post(id+"/comments", parameters).ToString());       // should give new comment's id

Console.WriteLine(fb.Get(postId +"/comments").ToString());    //should give you details
//for deleting
fb.Delete(newly_created_comment_id);   //should return true or false

Upvotes: 0

Sanket Patel
Sanket Patel

Reputation: 1160

string AccessToken = "...." // User's access token
FacebookClient fb = new FacebookClient(AccessToken);    
dynamic parameters = new ExpandoObject();
parameters.message = txtNewComment.Text.Trim();    
dynamic result=fb.Post(HiddenMyPostID.Value+"/comments", parameters);

Above is code that i use for posting new comment on any post of facebook. And It's working.

Upvotes: 0

K232
K232

Reputation: 1069

the fb.Post command seems to be correct. I use the same (in vb.net) and it works like expected...

Upvotes: 1

Related Questions