I am new to php and mysql. I have youtube and vimeo urls. I need to get the information of the video id, title and description from the url and save those information to the database. Can you help me please?

    2 months later

    For getting video details like title, description from youtube and vimeo video link use following code:

    $link = "http://www.youtube.com/watch?v=oHg5SJYRHA0&lololo"; // youtube link
    $video_id = explode("?v=", $link); // For videos like http://www.youtube.com/watch?v=...
    if (empty($video_id[1]))
        $video_id = explode("/v/", $link); // For videos like http://www.youtube.com/watch/v/..
    
    $video_id = explode("&", $video_id[1]); // Deleting any other params
    $video_id = $video_id[0];
    $apikey = 'YOUR_API_KEY'; //get api key
    $json = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/videos?id='.$videoid.'&key='.$apikey.'&part=snippet'));
    $ytdata = json_decode($json);
    print $ytdata to get all details...
    
    for vimeo :
    $url = ‘vimeo video url’;
    $video_id = substr(parse_url($url, PHP_URL_PATH), 1);
    $hash = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$video_id}.json"));
    print $hash and you will get all detail...
      Write a Reply...