Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter chaoste

    (@chaoste)

    Hi @victorrest,

    In general, I’d suggest you to look out for a separate plugin with its own embed widgets (e.g. https://ww.wp.xz.cn/plugins/embedalbum-pro/).

    If you really want to fix the endpoints (even though it will be removed completely this week), you might have a look into the new endpoints by Facebook for OEmbed:
    https://developers.facebook.com/docs/plugins/oembed/

    Example for FB posts:

    
    add_filter('oembed_providers', 'fr_replace_deprecated_fb_post_api', 10, 1);
    function fr_replace_deprecated_fb_post_api($providers) {
      unset($providers['#https?://www\.facebook\.com/.*/posts/.*#i']);
      $providers['#https?://www\.facebook\.com/.*/posts/.*#i'] = array('https://graph.facebook.com/v8.0/oembed_post', true);
      return $providers;
    }
    

    The filter for acquiring the access token just needs to consider this API, too:

    
    add_filter('oembed_fetch_url', 'fr_add_facebook_access_token', 10, 3);
    function fr_add_facebook_access_token($provider, $url, $args) {
      if (strpos($provider, 'instagram_oembed') !== -1 || strpos($provider, 'oembed_post')) {
        $response = @file_get_contents(FR_FACEBOOK_TOKEN_URI);
        if (!$response) {
          trigger_error("Couldn't retrieve an access token for Facebooks OEmbed API. Check your App ID, Client Secret & the permissions in the Facebook Developer Dashboard.", E_USER_WARNING);
          return $provider;
        }
        $response = json_decode($response);
        $access_token = $response->access_token;
        $provider .= '&access_token=' . $access_token;
      }
      return $provider;
    }
    

    @joyously Thanks for pointing out. Sadly, this means my work is useless :/

    Greetings,
    Thomas

    Thread Starter chaoste

    (@chaoste)

    Thanks for the quick response and carrying!

    Thomas

Viewing 2 replies - 1 through 2 (of 2 total)