Problem/Motivation

i posted the error in the wrong forum of video_embed_field: https://www.drupal.org/project/video_embed_field/issues/3519459

I get a Drupal 11 on node save form :

Fatal error: Declaration of Drupal\video_embed_facebook\Plugin\video_embed_field\Provider\Facebook::renderEmbedCode($width, $height, $autoplay) must be compatible with Drupal\video_embed_field\ProviderPluginInterface::renderEmbedCode($width, $height, $autoplay, $title_format = null, $use_title_fallback = true) in /var/www/html/docroot/web/modules/contrib/video_embed_facebook/src/Plugin/video_embed_field/Provider/Facebook.php on line 18

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

agelospanagiotakis created an issue. See original summary.

mably made their first commit to this issue’s fork.

mably’s picture

Title: Drupal 11 on node save form - Fatal error » Video Embed Field 3.0.x compatibility
Category: Bug report » Feature request
Related issues: +#3519459: Drupal 11 on node save form - Fatal error

I suggest to create a new 3.x branch for the 3.0.x compatible release.

mably’s picture

Status: Active » Needs review
mably’s picture

It would be interesting to be able to fetch the video title using the FB graph API.

Here is a piece of code ChatGPT generated that could be of some help to do that:

use Drupal::httpClient;

$video_id = '1234567890';
$access_token = 'your-access-token';
$response = \Drupal::httpClient()->get("https://graph.facebook.com/{$video_id}", [
  'query' => [
    'fields' => 'title',
    'access_token' => $access_token,
  ],
]);
$data = json_decode($response->getBody(), true);
$title = $data['title'] ?? 'Unknown Title';
mably’s picture

And it looks like the thumbnail fetching code needs to be updated too:

AI generated code posted here, just in case:

use Drupal::httpClient;

$video_id = '1234567890';
$access_token = 'your-access-token';
$response = \Drupal::httpClient()->get("https://graph.facebook.com/{$video_id}", [
  'query' => [
    'fields' => 'thumbnails',
    'access_token' => $access_token,
  ],
]);

$data = json_decode($response->getBody(), true);
$thumbnail_url = $data['thumbnails']['data'][0]['uri'] ?? NULL;

Looks like a patch have been provided here: https://www.drupal.org/project/video_embed_facebook/issues/3002106

mably’s picture

Will see what I can do if some people are interested.

renrhaf’s picture

Status: Needs review » Reviewed & tested by the community

+1, working !

mkrizaj’s picture

Hi @renrhaf and @mably.

I've recreated the patch and merged the changes from both PR into one. Please take a look and let me know what you think.

yannickoo made their first commit to this issue’s fork.