Programatically add and youtube video to wall post

旧巷老猫 提交于 2019-12-07 22:28:31

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/4499107/programatically-add-and-youtube-video-to-wall-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!