我知道这些 facebook api 的东西真的很让人头疼,在我在互联网上进行了较长时间的搜索之后,我只能找到一个消息 post API 到 facebook。我只想修改它以用于消息和图像发布。这是向facebook发布消息的相关代码。(Windows Phone 7)
private void PostToWall_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(txtMessage.Text))
{
MessageBox.Show("Enter message.");
return;
}
var fb = new FacebookClient(_accessToken);
fb.PostCompleted += (o, args) =>
{
if (args.Error != null)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(args.Error.Message));
return;
}
var result = (IDictionary<string, object>)args.GetResultData();
_lastMessageId = (string)result["id"];
Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Message Posted successfully");
txtMessage.Text = string.Empty;
btnDeleteLastMessage.IsEnabled = true;
});
};
var parameters = new Dictionary<string, object>();
parameters["message"] = txtMessage.Text;
fb.PostAsync("me/feed", parameters);
}
而且我还找到了一个图像邮政编码,但我无法将它集成到我的代码中。我认为方法彼此不合适。
这是图片邮政编码;
var photo = new WriteableBitmap(0, 0).FromResource("Background200x200.jpg");
FacebookClient app = new FacebookClient();
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters["access_token"] = _facebookAccessToken; //set in another method where I authenticate...
parameters["name"] = "my picture";
parameters["message"] = "this is a picture uploaded from my the facebook sdk";
var mediaObject = new FacebookMediaObject {
FileName = "Background200x200.jpg",
ContentType = "image/jpeg",
};
mediaObject.SetValue(photo.ToByteArray());
parameters["source"] = mediaObject;
app.ApiAsync(
UploadComplete,
null,
"https://graph.facebook.com/me/feed",
parameters,
HttpMethod.Post);
我只想发布带有消息的图像。如果你能给我一个将图像发布到 facebook 的示例链接(我一直在寻找一个现成编码的图像发布应用程序,即 Visual Studio 解决方案文件,我可以编译它并 XAP 它,并在我的手机上运行)
或者如果你能帮助我将我的信息海报演变为形象海报,我会非常高兴。
谢谢