I’am trying to develop app which takes a picture and sends it to my facebook fan page. Tried lots of different ways to do that, but at best it shares only a message and if i try to post a picture, then it posts on my timeline but not my fan page. So the question would be:
- how to upload picture and message to facebook page (if it’s possible)?
This is part of the code I’am using to post:
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read))
{
WriteableBitmap LoadedPhoto = new WriteableBitmap(0,0);
using (MemoryStream ms = new MemoryStream())
{
LoadedPhoto.SetSource(fileStream);
LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight, 0, 95);
ms.Seek(0, 0);
byte[] data = new byte[ms.Length];
System.Diagnostics.Debug.WriteLine(LoadedPhoto.PixelWidth);
ms.Read(data, 0, data.Length);
ms.Close();
var fbUpl = new Facebook.FacebookMediaObject
{
FileName = fileName,
ContentType = "image/jpg"
}.SetValue(data);
var parameters = new Dictionary<string, object>();
parameters["message"] = message;
parameters["file"] = fbUpl;
fb.PostAsync("{pageID}/photos", parameters, "post");
}
}
}
Thank You in advance.
Make sure you’re using the Page Access Token when you’re posting. That’s the only way the API knows that you want to act as the Page and not the logged in user.