Question

How can i extract the post id after posting it using the Facebook method Post() or PostTaskAsync() ??

i am using JSON.Net like this

var postObject = await fb.PostTaskAsync("/me/feed", postArgs);               
dynamic result = JsonConvert.DeserializeObject((string)postObject);
string id = result.id;

but it doesn't work !

What is the appropriate way to do it using facebook c# sdk v 6.x?

Was it helpful?

Solution

you don't need to deserialize the response to use it the way you want to just do this

dynamic postObject = await fb.PostTaskAsync("/me/feed", postArgs);    
string id = postObject.id;

I haven't used the PostTackAsync either, is it possible that postObject is not filled yet when you are trying to read it ? I would try just a regular Post fb.Post("/me/feed", postArgs) and see if that works.

if that doesn't solve it then you are going to have to set a break point and read the actual response. It is possible you don't have the right permissions and you are getting some type of error back. If this doesn't work for you - can you post the actual response that you are getting and it will be a lot easier to help

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top