Does anybody sucessfuly post picture to current user's wall? This is not working, if picture argument is existing picture url post is not shown! I'm using latest FB C# SDK 5.0.8 Beta ...
var args = new Dictionary<string, object>();
args["name"] = "My App";
args["link"] = @"http://apps.facebook.com/test/";
args["caption"] = "My Caption";
args["description"] = "My Description";
args["picture"] = @"http://www.test.com/test.jpeg";
args["message"] = "My Message";
args["actions"] = "";
FbClient.PostAsync(@"/me/feed", args);
Here is how I handled posting a photo to the Facebook User's wall. ImagePath and ImageName were string parameters that I passed into the function that contains this code.
var fbApp = new FacebookApp();
var auth = new CanvasAuthorizer(fbApp);
if (auth.IsAuthorized())
{
//Create a new dictionary of objects, with string keys
Dictionary<string, object> parameters = new Dictionary<string, object>();
string strDescription = txtDescription.Text;
//Add elements to the dictionary
if (string.IsNullOrEmpty(ImagePath) == false)
{
//There is an Image to add to the parameters
FacebookMediaObject media = new FacebookMediaObject
{
FileName = ImageName,
ContentType = "image/jpeg"
};
byte[] img = File.ReadAllBytes(ImagePath);
media.SetValue(img);
parameters.Add("source", media);
parameters.Add("message", strDescription);
try
{
dynamic result = fbApp.Api("/me/photos", parameters, HttpMethod.Post);
}
catch (Exception ex)
{
//handle error....
string strErr = ex.Message.ToString();
lblValidationMsg.Text = strErr;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With