Here is a simple piece of code to block an user from accessing your facebook fan page.
/// <summary>
/// Block annoying user from my fan page
/// </summary>
/// <param name="BlockUserId">Facebook userid to be blocked</param>
/// <param name="FacebookPageID">Facebook fanpage id</param>
/// <returns></returns>
private bool BlockFan(string BlockUserId, string FacebookPageID, string AccessToken)
{
try
{
var app = new FacebookClient(AccessToken);
dynamic parameters = new ExpandoObject();
parameters.method = "pages.blockFan";
parameters.uid = BlockUserId;
parameters.page_id = FacebookPageID;
app.Post("/" + FacebookPageID + "/users", parameters);
return true;
}
catch(Exception ex)
{
//Handle exception
return false;
}
}
Happy Coding!
/// <summary>
/// Block annoying user from my fan page
/// </summary>
/// <param name="BlockUserId">Facebook userid to be blocked</param>
/// <param name="FacebookPageID">Facebook fanpage id</param>
/// <returns></returns>
private bool BlockFan(string BlockUserId, string FacebookPageID, string AccessToken)
{
try
{
var app = new FacebookClient(AccessToken);
dynamic parameters = new ExpandoObject();
parameters.method = "pages.blockFan";
parameters.uid = BlockUserId;
parameters.page_id = FacebookPageID;
app.Post("/" + FacebookPageID + "/users", parameters);
return true;
}
catch(Exception ex)
{
//Handle exception
return false;
}
}
Happy Coding!
No comments:
Post a Comment