使用Facebook共享对话框从WPF应用程序共享图像

时间:2018-09-12 14:14:37

标签: c# wpf facebook facebook-graph-api

我正在使用WPF C#Desktop应用程序。我尝试在Facebook上发布图片,但是由于Facebook已弃用该版本或删除了某些范围而无法发布。

当前它正在使用“共享”对话框: https://developers.facebook.com/docs/sharing/reference/share-dialog

对于桌面应用程序: https://developers.facebook.com/docs/sharing/for-devices

如何从桌面应用程序发出和呼叫。并在Facebook墙上张贴图片?

public void UploadContent()
{
    string photoAlbumID = "199967900755629";

    FacebookMediaObject facebookUploader = new FacebookMediaObject { FileName = "Carnival-Mask-Costume-Ideas-800x600.jpg", ContentType = "image/png" };

    //var bytes = File.ReadAllBytes(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + "\\" + facebookUploader.FileName);
    var bytes = File.ReadAllBytes(@"D:\Gallery\Carnival-Mask-Costume-Ideas-800x600.jpg");
    facebookUploader.SetValue(bytes);
    var postInfo = new Dictionary<string, object>();
    postInfo.Add("message", "test photo");
    postInfo.Add("image", facebookUploader);
    postInfo.Add("access_token", fbtoken.AccessToken);
    var fbResult = fbtoken.Post("/" + photoAlbumID + "/photos", postInfo);
    dynamic result = (IDictionary<string, object>)fbResult;
}

0 个答案:

没有答案