Data migration with PHP

This question already has an answer here:

  • How do I get a YouTube video thumbnail from the YouTube API? 29 answers

  • $link = 'http://www.youtube.com/watch?v=hYVVCRqTz1Q';

    Now match if the URL is a valid Youtube Link by matching it with Pattern.

    $ypattern= "#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch?v=([-|~_0-9A-Za-z]+)&?.*?)#";
    if(preg_match_all($ypattern,$link, $output))
    { 
        foreach ($output[4] AS $video_id)
        {
    

    Youtube Headers

    $headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $video_id)`;
    
         if (strpos($headers[0], '200'))
         {
        $youtube = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=1');
                $json = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=2&alt=jsonc'));
    

    Thumbnail >

    $thumbnail = $json->data->thumbnail->sqDefault;
                    }
                }
            }
    
    链接地址: http://www.djcxy.com/p/28900.html

    上一篇: 嵌入YouTube视频

    下一篇: 使用PHP进行数据迁移