How can I retrieve YouTube video details from video URL using PHP? -
using php, how can video information title, description, thumbnail youtube video url e.g.
http://www.youtube.com/watch?v=b4crkpbgqzu
you can data youtube oembed interface in 2 formats: xml , json
interface address: http://www.youtube.com/oembed?url=youtubeurl&format=json
use php function data
function get_youtube($url){ $youtube = "http://www.youtube.com/oembed?url=". $url ."&format=json"; $curl = curl_init($youtube); curl_setopt($curl, curlopt_returntransfer, 1); $return = curl_exec($curl); curl_close($curl); return json_decode($return, true); } $url = // youtube video url // display data print_r(get_youtube($url)); don't forget enable extension=php_curl.dll in php.ini
Comments
Post a Comment