Showing posts with label remove post. Show all posts
Showing posts with label remove post. Show all posts

Tuesday, November 22, 2011

Remove a post from Facebook fan page using C# SDK

Wondering how to delete (or) remove a post (or) comment from a facebook fan page wall, here it is!

///<summary\>
/// Remove post from facebook fanpage wall
///</summary\>
///<param name="accesstoken"\>user access token</param>
///<param name="fanPageId"\>Fan Page Id</param>
///<param name="contentId"\>Post or Comment Id </param>
public void removePost(string accesstoken, string fanPageId, string contentId)
{
       var fb = new FacebookClient();
       dynamic parameters = new ExpandoObject();
       parameters.access_token = accesstoken;
       parameters.uid = fanPageId;
       //pass the content id you like to remove - pageid_postid format
     if(fb.Delete("/" + contentId, parameters))
       {

                  Console.Write("Delete Success!");
       }
       else
       {
                  Console.Write("Delete failed!");
       }
}
 
Call this method and the content is cleaned (removed) from your fanpage wall.

Happy coding!