Problem/Motivation

The current facebook API being used is going to be deprecated. We can leverage what the media_entity_instagram module did in #3163542: Add support for Instagram/Facebook's new oembed API and use a proper oEmbed provider to fix.

Error retrieving oEmbed data for a Facebook media entity: Client error: `GET https://www.facebook.com/plugins/video/oembed.json/?url=https://www.facebook.com/ServiceNSW/videos/663130171167174/` resulted in a `400 Bad Request` response: This endpoint is deprecated and will be shut down on October 24th 2020. Until then, you can resolve this error by retryi

Steps to reproduce

Try and create a Facebook media item.

Proposed resolution

Create new major release and migrate to an oEmbed provider as per #3163542: Add support for Instagram/Facebook's new oembed API

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acbramley created an issue. See original summary.

kaszarobert’s picture

Priority: Normal » Critical

Are there any plans for a new release? The date is approaching and without a fix the module won't work anymore.

kaszarobert’s picture

I made a quick fix for the problem without major changes in the code:
- I replaced the URLs with the new API ones,
- I set caching the results for 10 minutes because there're rate limits with the new API.
- I made a new form where you can set the needed Facebook App Id and App Secret as config values.

After applying this patch, you need to:
1. clear the caches
2. visit /admin/config/media/facebook-settings as admin, fill the App Id and App Secret and click save.

acbramley’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests
FileSize
6.08 KB
398 bytes

#3 works for now, this patch adds a fix for getting the url via getMetadata as the oEmbed data no longer contains that key.

However we need to properly convert this to an oEmbed resource ala the issue in the IS. I had a good look through how this might be done and mostly it should be identical to the instagram module but it's a bit harder due to facebook's different urls for different resources.

We also have the added complication of allowing users to paste the full iframe HTML into the source field.

joewhitsitt’s picture

Thanks! We are using #4 on our sites and passing the credentials in via Acquia's secrets functionality: https://docs.acquia.com/resource/secrets/

csc4’s picture

Was hoping to test as requested - but there's a composer error

8.x-2.x: PHP 5.6 & MySQL 5.5, D8.9 Composer error. Unable to continue.

Adamam’s picture

Hi, Thanks for #4 but I am getting error for ALL embedded posts on my site :

Video Unavailable
This video may no longer exist, or you don't have permission to view it.

Why? How to fix it?

Adamam’s picture

I fixed it, Thanks

line 125 and 129 of the FacebookFetcher.php were both returning

return 'https://graph.facebook.com/v8.0/oembed_video';
line 129 was supposed to return post not video since I embed post also
return 'https://graph.facebook.com/v8.0/oembed_post';

jeeba’s picture

Ok, tested it #4 on Drupal 8.9.12 and it works. Also I put the patch for creation of new Facebook Media and they work well together. https://www.drupal.org/project/media_entity_facebook/issues/3120085#comm...

MrPaulDriver’s picture

I am unable to get this working this on Drupal 9.1

I think it may be incompatible with the patch from #3160072: undefined function file_unmanaged_copy

OCTOGONE.dev’s picture

I am unable to get this working this on Drupal 8.9.

Can we have a status on this. Are you planning to release a new version that correct this problem? Date?

Thank you.

jlj’s picture

Patch in #4 work for me with Media entity facebook 8.x-2.0-beta1 and Drupal 8.9.13.

Note in (admin/config/media/facebook-settings): To use this module you need a Facebook developer account. In the your Facebook developer dashboard you have to create an App that uses the oEmbed API.

bkosborne’s picture

Hi all, I'm working on getting this fixed and a new release out. Probably going to go with a version 3 so we can start using semantic versioning.

bkosborne’s picture

FileSize
6.56 KB

Here's a re-roll that works with latest 2.x release.

bkosborne’s picture

FileSize
6.44 KB

Oops had some extra lines in that one.

  • bkosborne committed ed67524 on 3.x
    Issue #3176739 by bkosborne, acbramley, kaszarobert: Add support for...
bkosborne’s picture

Version: 8.x-2.x-dev » 3.x-dev
Status: Needs work » Fixed

Perfect is the enemy of good - so I decided to more or less commit this as is (I cleaned a few things up) and tagged a new release 3.0.0-beta1. I marked the 1.x and 2.x branches as unsupported.

I started working towards updating the media source plugin to be based on core's oembed plugin, just like the Instagram module did, but soon realized I'd be copying most of what Instagram module already does. At that point, it makes more sense to just combine these two modules. They use the exact same API after all. The Instagram module is more popular so I'll create an issue there to propose merging this module into that one.

acbramley’s picture

Great idea, cheers @bkosborne!

bkosborne’s picture

OCTOGONE.dev’s picture

Hello,
thank you very mutch for the update. i can now add facebook url, that was not possible before this update. the media is created. But, nothing is displayed on the site. After checking the code, no HTML is writen. Note that instagram entity media is working on my site. i did some test but find nothing.

Note : i've updated the database and cleared the cache.

Other users have the same problem?

bkosborne’s picture

  1. Have you provided the facebook app ID and secret in the new settings page?
  2. Check your Drupal logs (enable dblog if you need to). Clear cache and visit a page with the embedded post. Check log for errors.
OCTOGONE.dev’s picture

@bkosborne
indeed the log give me an error about facebook query, the problem was that my facebook app was in dev mode, it must be online. Strange that instagram was working.

It works

Thank you

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.