gpt4 book ai didi

c# - 将参数传递给 Facebook Open Graph API

转载 作者:太空宇宙 更新时间:2023-11-03 16:32:46 26 4
gpt4 key购买 nike

我正在尝试使用 C# SDK 将视频上传到 Facebook 开放图表。视频似乎可以正常上传,并且我获得了该事件的 ID,但只显示了示例元数据。

经过一番挖掘,我发现了这个:

Before being able to publish an Open Graph action for a user and having define its corresponding connected object type in Step 3, you will now need to create a publicly accessible web page that represents this object using Open Graph metatags. Once this object page is created, you can use the Graph API to publish an action.

由于这是一个客户端应用程序,我没有可以将 Facebook 引用到的网页。那么如何传入正确的参数呢?

这是我的代码:

var parameters = new Dictionary<string, object>();
parameters["source"] = new FacebookMediaObject { ContentType = "video/mpeg", FileName = "video.mpeg" }.SetValue(File.ReadAllBytes(@"D:\sample video.MP4"));
parameters["og:title"] = "Sample video";
parameters["title"] = "Sample video";
parameters["og:description"] = "Test description";
parameters["highlight"] = "http://samples.ogp.me/287287444686523"; // If I don't put this, the upload fails
fb.PostAsync("/me/myobjectname:share", parameters);

谢谢!

最佳答案

对于版本 6,您可以:

var fb = new FacebookClient(accessToken);
string attachementPath = @"C:\image.jpg";

using (var stream = File.OpenRead(attachementPath))
{
dynamic result = fb.Post("me/photos",
new
{
message = "upload using Facebook C# SDK",
file = new FacebookMediaStream
{
ContentType = "image/jpg",
FileName = Path.GetFileName(attachementPath)
}.SetValue(stream)
});
}

更多详情 here .

关于c# - 将参数传递给 Facebook Open Graph API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10307843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com