Programatically add and youtube video to wall post
How can i embeded an youtube video in the facebook wa开发者_开发技巧ll? 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!
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.
精彩评论