How do I enable the integrated video recording when I post a facebook link to a YouTube video through my app?

Facebook.prototype.post = function(options) { var data = { access_token: this.data.token, // message: options.message, link: options.link, }; if (options.type == 'image') data.picture = options.image; var url = 'https://graph.facebook.com/me/feed'; if (options.friend !== undefined) url = 'https://graph.facebook.com/' + escape(options.friend) + '/feed'; $.ajax({ type: 'post', dataType: 'json', url: url, data: data, success: options.success, error: options.error }); 

};

See attached

+4
source share
1 answer

How to watch the video:

Refresh . If you want to embed a video based on the link you get from the facebook api, you can do something like:

 <object width="640" height="385"> <param name="movie" value="http://www.youtube.com/v/vX07j9SDFcc?autoplay=1"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/vX07j9SDFcc?autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed> </object> 

Just replace the link on YouTube.

If you want to ?autoplay=1 it, REMEMBER TO TURN ON ?autoplay=1 Autoplay ?autoplay=1 .

How to share video :

Here are two ways to do this:

METHOD 1 . Open the popup with the url:

http://www.facebook.com/sharer.php?u=[Youtube Link]

Sample code for implementation:

 ...onclick=function() { window.open('http://www.facebook.com/sharer.php?u=[Youtube Link]'); } 

The popup that opens will look like this: popup

METHOD 2 : use the Javascript API:

It might look more professional because you can display your message as an iframe overlay.

  var share = { method: 'stream.share', u: '[Youtube Link]' }; FB.ui(share, function(response) { console.log(response); }); 

Here is the documentation on which I based my code:

http://developers.facebook.com/docs/reference/javascript/FB.ui

RESULT

In any case, after the user clicks a share, he should appear in the news feed: Example Screenshot

+4
source

All Articles