有人成功地将图片发布到当前用户的墙上吗?这是行不通的,如果图片参数是现有的图片 url 则不会显示!我正在使用最新的 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);
以下是我如何将照片发布到 Facebook 用户的墙上。 ImagePath 和 ImageName 是我传递到包含此代码的函数中的字符串参数。
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;
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)