以编程方式将 YouTube 视频添加到墙贴

发布于 2024-10-08 18:41:59 字数 990 浏览 2 评论 0原文

如何在 Facebook 墙上嵌入 YouTube 视频?我尝试使用“源”成员传递视频网址,但没有成功。在检查手动发布的提要的 json 后,我发现 FB 的服务器代码进行了一些处理来实现这一点。

该提要向我展示了这一点:

"id": "100001460921297_170524112986785",
         "from": {
            "name": "Fw As",
            "id": "100001460921297"
         },
         "message": "In SBSR 16 July 2010 Portugal",
         "picture": "http://external.ak.fbcdn.net/safe_image.php?d=9f79134b5acff03a2d60adb0320dbc8b&w=130&h=130&url=http%3A%2F%2Fi.ytimg.com%2Fvi%2FTOypSnKFHrE%2F0.jpg",
         "link": "http://www.youtube.com/watch?v=TOypSnKFHrE",
         "source": "http://www.youtube.com/v/TOypSnKFHrE&autoplay=1",
         "name": "The Strokes - Last Nite",
         "caption": "www.youtube.com",
         "description": "Music video by The Strokes performing Last Nite. (C) 2001 BMG",
         "icon": "http://static.ak.fbcdn.net/rsrc.php/yj/r/v2OnaTyTQZE.gif",

有没有办法通过 c# sdk 实现此目的?到目前为止我找不到任何有用的信息。

有什么想法吗?

谢谢,圣诞快乐!

How can i embeded an youtube video in the facebook wall? I tried to pass the video url using the "source" member, but didn't work. After checking the json of a feed posted manually i see that there is some handling by FB's server code to make it happen.

The feed shows me this:

"id": "100001460921297_170524112986785",
         "from": {
            "name": "Fw As",
            "id": "100001460921297"
         },
         "message": "In SBSR 16 July 2010 Portugal",
         "picture": "http://external.ak.fbcdn.net/safe_image.php?d=9f79134b5acff03a2d60adb0320dbc8b&w=130&h=130&url=http%3A%2F%2Fi.ytimg.com%2Fvi%2FTOypSnKFHrE%2F0.jpg",
         "link": "http://www.youtube.com/watch?v=TOypSnKFHrE",
         "source": "http://www.youtube.com/v/TOypSnKFHrE&autoplay=1",
         "name": "The Strokes - Last Nite",
         "caption": "www.youtube.com",
         "description": "Music video by The Strokes performing Last Nite. (C) 2001 BMG",
         "icon": "http://static.ak.fbcdn.net/rsrc.php/yj/r/v2OnaTyTQZE.gif",

Is there way to achieve this via the c# sdk? I couldn't find any info helpfull about it so far.

Any ideas?

Thanks and merry christmas!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溇涏 2024-10-15 18:41:59

如果您使用 Facebook C# SDK,那么在成功进行身份验证和授权后,您需要发布链接。

我假设 _FacebookApp 是 FacebookApp 类的实例并且您已获得授权,那么代码将是:

        var parameters = new Dictionary<string, object>();

        parameters.Add("message", Commentary);
        parameters.Add("link", Link);
        if (!String.IsNullOrEmpty(ThumbnailImageUrl))
            parameters.Add("picture", ThumbnailImageUrl);

        try
        {
            _FacebookApp.Post("me/feed", parameters);
        }
        catch (Exception ex)
        {
            return ex.Message;
        }

其中 Commentary 是用户关于此链接的可选消息,例如:“伙计们,检查一下”,

Link 是共享的 URL ,例如:“http://www.youtube.com/watch?v=_OBlgSz8sSM”,

ThumbnailImageUrl 是链接帖子中使用的缩略图的 URL,例如:“http://i.ytimg.com/vi/ _OBlgSz8sSM/0.jpg”。

希望它会有所帮助。

干杯。

If you use Facebook C# SDK, then after successful authentication and authorization you need to post a link.

I assume that _FacebookApp is instance of FacebookApp class and you are authorized, then the code will be:

        var parameters = new Dictionary<string, object>();

        parameters.Add("message", Commentary);
        parameters.Add("link", Link);
        if (!String.IsNullOrEmpty(ThumbnailImageUrl))
            parameters.Add("picture", ThumbnailImageUrl);

        try
        {
            _FacebookApp.Post("me/feed", parameters);
        }
        catch (Exception ex)
        {
            return ex.Message;
        }

where Commentary is an optional message from the user about this link, e.g.: "Guys, check it out",

Link is the URL that was shared, e.g.:"http://www.youtube.com/watch?v=_OBlgSz8sSM",

ThumbnailImageUrl is a URL to the thumbnail image used in the link post, e.g.:"http://i.ytimg.com/vi/_OBlgSz8sSM/0.jpg".

Hope it will help.

Cheers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文