jemsz Posted June 27, 2013 Share Posted June 27, 2013 Gretings all. Right now i use wordpress and in my post i can add a Video by entering the Youtube address into a Custom field called "video_url" and then it outputs the video on my site wich works easy, here it is: <div class="video"> <html><center> <?php $meta_value = get_post_meta($post->ID, 'video_url', true); if($meta_value){ $url = parse_url($meta_value); $id = 0; if($url['host'] == 'youtu.be'){$id = ltrim($url['path'],'/');} else if(strpos($url['path'],'embed') == 1){$id = end(explode('/',$url['path']));} else{parse_str($url['query']);$id = $v;} echo '<p><iframe width="540" height="355" frameborder="1" allowfullscreen="true" src="http://www.youtube.com/embed/'.$id. '?version=3&theme=light&fs=1&rel=0&cc_load_policy=1&iv_load_policy=1&modestbranding=1" type="application/x-shockwave-flash" allowScriptAccess="always" allowfullscreen="true" width="600" height="355"> </iframe></p>'; } ?> </div> However i am tring to add this Modification here in wich adding the video link custom field will also bring back the youtube video title and descripiton, <?php $video_id = ’48J_DIZBNyE’; $video_info = simplexml_load_file(‘http://gdata.youtube.com/feeds/api/videos/’.$video_id.’?v=1′); echo $video_info->title . ‘<hr>’; // title echo $video_info->content; // description ?> Could anyone please help me implement the bottom code with the top piece of code !! Mucg respect>< Thanks Quote Link to comment https://forums.phpfreaks.com/topic/279630-php-simple-question/ Share on other sites More sharing options...
dalecosp Posted June 27, 2013 Share Posted June 27, 2013 (edited) Does this help you? <div class="video"> <html><center> <?php $meta_value = get_post_meta($post->ID, 'video_url', true); if($meta_value){ $url = parse_url($meta_value); $id = 0; if($url['host'] == 'youtu.be'){ $id = ltrim($url['path'],'/'); } else if(strpos($url['path'],'embed') == 1){ $id = end(explode('/',$url['path'])); } } else { parse_str($url['query']); $id = $v; } $video_info = simplexml_load_file(‘http://gdata.youtube.com/feeds/api/videos/’.$id.’?v=1'); echo '<h3>'.$video_info->content.'</h3><hr /><p><iframe width="540" height="355" frameborder="1" allowfullscreen="true" src="http://www.youtube.com/embed/'.$id. '?version=3&theme=light&fs=1&rel=0&cc_load_policy=1&iv_load_policy=1&modestbranding=1" type="application/x-shockwave-flash" allowScriptAccess="always" allowfullscreen="true" width="600" height="355"> </iframe></p><p>'.$video_info->content;.'</p>'; ?> </div>NB: *Not* linted.... Edited June 27, 2013 by dalecosp Quote Link to comment https://forums.phpfreaks.com/topic/279630-php-simple-question/#findComment-1438244 Share on other sites More sharing options...
jemsz Posted June 28, 2013 Author Share Posted June 28, 2013 Thanks alot! Cheers for the help! Quote Link to comment https://forums.phpfreaks.com/topic/279630-php-simple-question/#findComment-1438326 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.