https://play.google.com/store/apps/details?id=ulusanyazilim.com
Etiket: Youtube
Youtube Oembed JSON API
<?php$url = "http://www.youtube.com/watch?v=CvBfHwUxHIk";//burası değişken$oembedurlcreate = "http://www.youtube.com/oembed?url=".$url."&format=json";$curl = curl_init($oembedurlcreate);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);$html=curl_exec($curl);curl_close($curl);$result = json_decode($html, true);echo $result["thumbnail_url"]."<br>";//http://i.ytimg.com/vi/CvBfHwUxHIk/hqdefault.jpgecho $result["provider_url"]."<br>";//http://www.youtube.com/echo $result["thumbnail_height"]."<br>";//360echo $result["type"]."<br>";//videoecho $result["provider_name"]."<br>";//YouTubeecho $result["version"]."<br>";// 1.0echo $result["html"]."<br>";//html5 video oynacıtıcını görüntülerecho $result["author_name"]."<br>";//RihannaVEVOecho $result["width"]."<br>";//459echo $result["title"]."<br>";//Rihanna - Umbrella (Orange Version) ft. JAY-Zecho $result["height"]."<br>";//344echo $result["thumbnail_width"]."<br>";//480echo $result["author_url"]."<br>";//http://www.youtube.com/user/RihannaVEVO?>
Youtube Url Expander
Herhangi bir youtube adresini sitenizde iframe içinde izlemenize olanak sağlar.
<?phpfunction checkValues($value){$value = trim($value);if (get_magic_quotes_gpc()) {$value = stripslashes($value);}$value = strtr($value,array_flip(get_html_translation_table(HTML_ENTITIES)));$value = strip_tags($value);$value = mysql_real_escape_string($value);$value = htmlspecialchars ($value);return $value;}function auto_link_text($text) {$pattern = '#\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#';return preg_replace_callback($pattern, 'auto_link_text_callback', $text);}function auto_link_text_callback($matches) {$max_url_length = 50;$max_depth_if_over_length = 2;$ellipsis = '…';$url_full = $matches[0];$url_short = '';if (strlen($url_full) > $max_url_length) {$parts = parse_url($url_full);$url_short = $parts['scheme'] . '://' . preg_replace('/^www\./', '', $parts['host']) . '/';$path_components = explode('/', trim($parts['path'], '/'));foreach ($path_components as $dir) {$url_string_components[] = $dir . '/';}if (!empty($parts['query'])) {$url_string_components[] = '?' . $parts['query'];}if (!empty($parts['fragment'])) {$url_string_components[] = '#' . $parts['fragment'];}for ($k = 0; $k < count($url_string_components); $k++) {$curr_component = $url_string_components[$k];if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) {if ($k == 0 && strlen($url_short) < $max_url_length) {$url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short));}$url_short .= $ellipsis;break;}$url_short .= $curr_component;}} else {$url_short = $url_full;}preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $url_short, $cikti);return '<p><iframe width="420" height="213" src="http://youtube.com/embed/'.$cikti[1].'"frameborder="0" allowfullscreen></iframe></p>';}echo auto_link_text(checkValues("https://www.youtube.com/watch?v=uaVxC4syxPY"));
Çıktısı
https://www.youtube.com/watch?v=3vIMG7fTVMc
Youtube video adresi ile video, resim ve başlık çekmek
Youtube adresini $url değişkenine yazarak ilgili verilere ulaşabilirsiniz. Alttaki istediğiniz değişkenleri echo ile yazdırabilirsiniz.
<?php header('Content-Type: text/html; charset=utf-8');$url="http://www.youtube.com/watch?v=E2tMV96xULk";//istediğiniz urlyi yazınız//ID AYIRMAparse_str( parse_url( $url, PHP_URL_QUERY ), $videodizi );$xml=simplexml_load_file("http://gdata.youtube.com/feeds/api/videos/".$videodizi['v']."?v=2");//İSTEDİĞİNİZİ BAŞINA ECHO KOYUP KULLANABİLİRSİNİZ$kucukvideoplayer='<iframe width="480" height="360" src="http://www.youtube.com/embed/'.$videodizi['v'].'?enablejsapi=1&autoplay=0&cc_load_policy=0&iv_load_policy=1&loop=0&modestbranding=0&rel=1&showinfo=1&autohide=2&theme=dark&color=red&wmode=opaque&vq=&controls=2&" frameborder="0" type="text/html" allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen=""></iframe>';$buyukboyresim='<img src="http://img.youtube.com/vi/'.$videodizi['v'].'/hqdefault.jpg" alt="'.$xml->title.'" width="480" height="360">';$ortaboyresim='<img src="http://img.youtube.com/vi/'.$videodizi['v'].'/mqdefault.jpg" alt="'.$xml->title.'" width="320" height="180">';$kucukboyresim='<img src="http://img.youtube.com/vi/'.$videodizi['v'].'/default.jpg" alt="'.$xml->title.'" width="120" height="90">';$youtubevideolink='<a href="'.$xml->link['0']['href'].'" title="'.$xml->title.'">'.$xml->title.'</a>';$videobaslik=$xml->title;$tamekranvideo='<iframe src="'.$xml->content['src'].'" height="100%" width="100%" frameborder="0">Your browser doesnot support iframes <a href="'.$xml->link['0']['href'].'" alt="'.$xml->title.'">'.$xml->title.'</a>click here to view the page directly. </a></iframe>';//tamekran videoda body{margin:0;padding:0} css eklemeyi unutmayınız. ulusanyazilim@gmail.com #ulusanyazilim @ulusanyazilim?>*/