Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#15 | 3176739-15.patch | 6.44 KB | bkosborne |
#4 | interdiff-3176739-3-4.txt | 398 bytes | acbramley |
#4 | 3176739-4.patch | 6.08 KB | acbramley |
Comments
Comment #2
kaszarobertAre there any plans for a new release? The date is approaching and without a fix the module won't work anymore.
Comment #3
kaszarobertI 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.
Comment #4
acbramley CreditAttribution: acbramley at PreviousNext for Service NSW commented#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.
Comment #5
joewhitsittThanks! We are using #4 on our sites and passing the credentials in via Acquia's secrets functionality: https://docs.acquia.com/resource/secrets/
Comment #6
csc4 CreditAttribution: csc4 commentedWas 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.
Comment #7
Adamam CreditAttribution: Adamam commentedHi, Thanks for #4 but I am getting error for ALL embedded posts on my site :
Why? How to fix it?
Comment #8
Adamam CreditAttribution: Adamam commentedI 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';
Comment #9
jeeba CreditAttribution: jeeba as a volunteer and commentedOk, 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...
Comment #10
MrPaulDriver CreditAttribution: MrPaulDriver commentedI 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
Comment #11
OCTOGONE.dev CreditAttribution: OCTOGONE.dev commentedI 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.
Comment #12
jlj CreditAttribution: jlj commentedPatch 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.
Comment #13
bkosborneHi 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.
Comment #14
bkosborneHere's a re-roll that works with latest 2.x release.
Comment #15
bkosborneOops had some extra lines in that one.
Comment #17
bkosbornePerfect 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.
Comment #18
acbramley CreditAttribution: acbramley at PreviousNext for Service NSW commentedGreat idea, cheers @bkosborne!
Comment #19
bkosborneComment #20
OCTOGONE.dev CreditAttribution: OCTOGONE.dev commentedHello,
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?
Comment #21
bkosborneComment #22
OCTOGONE.dev CreditAttribution: OCTOGONE.dev commented@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