I need to share image an to my facebook page. I used the following code:
string accessToken = ConfigurationManager.AppSettings["ACCESSTOKEN"].ToString();
string pageId = ConfigurationManager.AppSettings["PAGEID"].ToString();
string ImagePath = Server.MapPath("Images/img.jpg");
FacebookClient fb = new FacebookClient(accessToken);
fb.AppId = ConfigurationManager.AppSettings["APPID"].ToString();
fb.AppSecret = ConfigurationManager.AppSettings["APPSECRET"].ToString();
var imgstream = File.OpenRead(ImagePath);
dynamic res = fb.Post(pageId + "/photos", new
{
message = "Test Message",
file = new FacebookMediaStream
{
ContentType = "image/jpg",
FileName = Path.GetFileName(ImagePath)
}.SetValue(imgstream)
});
It worked and displayed in "Recent posts by other on [page name]" with my name. Im the admin of this page. For me It should display as posted by admin. help me guys!!