Automatic-Featured-Images-from-Videos icon indicating copy to clipboard operation
Automatic-Featured-Images-from-Videos copied to clipboard

Consideration: Add Facebook support

Open absentio opened this issue 6 years ago • 8 comments

It would be great to add Facebook Video support, as it is one of the most used video uploading platform.

absentio avatar Mar 12 '19 15:03 absentio

Do you have any examples of FB videos that would be embed-able in WordPress content? I tried one but it didn't work and threw errors. We'd also need some sort of static image API endpoint to fetch content from by unique ID. Vimeo and Youtube provide those, which is why they're the two that get the most focus.

We don't generate the images themselves, we simply fetch and programmatically upload existing video screenshots.

tw2113 avatar Mar 12 '19 15:03 tw2113

Thank you for replying. I was trying to help you making this, I am not an advanced developer but I am studying computer engineering and I know a bit of PHP. Facebook content is automatically embedded in a wordpress article if the url is pasted into the content. To get Facebook thumbnail you have to look at: https://graph.facebook.com/VIDEOID/picture?redirect=false EDIT: In this way,without having an facebook appID , you can only get the small thumbnail. To get the big thumbnails you have to use facebook API.

This is regex for facebook video urls:

function wds_check_for_facebook( $content ) {
	if ( preg_match( '^(?:(?:https?:)?\/\/)?(?:www\.)?facebook\.com\/[a-zA-Z0-9\.]+\/videos\/(?:[a-zA-Z0-9\.]+\/)?([0-9]+)', $content, $facebook_matches ) ) {
		return $facebook_matches[1];
	}

	return false;
}

absentio avatar Mar 12 '19 15:03 absentio

An example of a video that will work as a whole, though won't be playable in the editor screen:

https://www.facebook.com/PetSemataryMovie/posts/2218578548192717

Extra note about the graph URL, you can append &height=XYZ and get larger images.

@absentio if you can point us to the right part of FB's documentation for API and Graph stuff that would show how to do the image fetching without requiring apps set up, we could look into this much more readily. We're not going to be able to do much if they do require an app, and I'd really rather not try to tie WebDevStudios to provide one for all the users.

tw2113 avatar Mar 12 '19 16:03 tw2113

If you use the post link instead of the video link the /picture won't work. the &height=XYZ doesn't seem to work without a Facebook access token. I tried doing some online researches but it seems to be impossible without having a Facebook APP. You could let the users use their own app ID and access tokens, so you won't have any problems. This is what most Facebook wordpress plugins do. I would like to help you and I've tried my best, I will keep searching for new solutions. Sorry for my English but I am not a native English or American speaker.

absentio avatar Mar 12 '19 16:03 absentio

You've communicated well enough that I haven't scratched my head going "what?". We can definitely leave this open as well as more information gets found and whatnot. Ideally we would want this as seamless as possible, so avoiding app needs would be a benefit. Alternatively, that could be its own extending plugin as well. There's room to work here.

tw2113 avatar Mar 12 '19 16:03 tw2113

Using Graph 3.2 I've found VIDEOID/thumbnails?access_token=YOURACCESS_TOKEN you will get a json with all the video thumbnails. The one with the field "is_preferred": true will be the real video thumbnail, but we will have to do the filtering on our own as it is not possible through the API. I never coded for WordPress before, I've rarely made some modifications to themes and plugins, I don't think it will be hard to add it as we only have to get the URL of the thumbnail, in my free time I will begin studying git so it will be easier to cooperate!

absentio avatar Mar 12 '19 17:03 absentio

We have more requests for this, as well as some example code over at https://wordpress.org/support/topic/facebook-video-embed/

I think the biggest things are going to be:

  1. Setting up and wiring up an authentication method to get the necessary access tokens, as well as keep those refreshed and renewed.
  2. Making sure we keep up with Facebook's ongoing changes with their graph platform.

One nice thing that's been evident for a long time with Vimeo and Youtube is that those endpoints have simply not changed at all, allowing for a lot of stability with the plugin.

tw2113 avatar Jun 06 '24 13:06 tw2113

I appreciate you guys looking into this - wish they made it as simple as YT and Vimeo does.

tlock878 avatar Jun 07 '24 05:06 tlock878