views:

52

answers:

1
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

+1  A: 

How to view video:

Update: If you want to be able to embed a video based on the link you get from the facebook api, you could do something like:

<object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/vX07j9SDFcc?autoplay=1"&gt;&lt;/param&gt;
<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 youtube link.

If you want it to autoplay, REMEMBER TO INCLUDE THE ?autoplay=1.

How to share video:

Here are two ways to do this:

METHOD 1: Open a Popup with the URL format:

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

Sample code to implement this would be:

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

The popup that will open will look like: popup

METHOD 2: Use Javascript API:

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

 var share = {
   method: 'stream.share',
   u: '[Youtube Link]'
 };

 FB.ui(share, function(response) { console.log(response); });

Here's the documentation I based my code from:

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

RESULT:

Either way, after the user clicks share, it should appear in the news feed:Example Screenshot

Kranu
Oops! Sorry, I didn't realize that because it wasn't super clear. I'm working on editing my post now.
Kranu
Maybe you don't get what I was saying about the Popups. When someone wants to share the video, you open up that URL. Then, in the news feed, it appears as what you wanted (I edited my post to show a screenshot of what it looks like)
Kranu
If you're using the API, there's no need to use the sharer.php because the API automatically does it for you.
Kranu
Where'd you get popup:'popup' from? I've updated my post again to more clearly state the TWO methods. One is super easy to implement, but the second uses the API.
Kranu
Hang on so now I'm confused about your question. Is this application being used to VIEW the feed? OR is it being used to SHARE a video? All this time I thought you wanted to share the video that way, but based on the code you updated, it look like you want to view the feed.
Kranu
The code you posted is to view the feed. So in other words, you want the video to be played in an embed instead of having to the user open Youtube?
Kranu
I'm sorry, but you posted your comment after I left StackOverflow.
Kranu

related questions