Skip to content

Instantly share code, notes, and snippets.

@vc27
Created February 24, 2012 23:36
Show Gist options
  • Save vc27/1904612 to your computer and use it in GitHub Desktop.
Save vc27/1904612 to your computer and use it in GitHub Desktop.
Use built in WP_oEmbed for fetching data
<?php
require_once( ABSPATH . WPINC . '/class-oembed.php' );
$WP_oEmbed = new WP_oEmbed();
$provider = $WP_oEmbed->discover( $url );
$data = $WP_oEmbed->fetch( $provider, $url );
if ( isset( $data ) AND $data != false ) { print_r($data); }
@jetonr
Copy link

jetonr commented Dec 22, 2013

or

require_once( ABSPATH . WPINC . '/class-oembed.php' );
$oembed = _wp_oembed_get_object();
$provider = $oembed->discover( $video_link );
$data = $oembed->fetch( $provider, $video_link );

if ( isset( $data ) AND $data != false ) { print_r($data); }

@jetonr
Copy link

jetonr commented Dec 22, 2013

I cant figure out why some providers don't work when using this method. I tried hulu and qik they both return nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment