PHP - Get Latest Video From Youtube Playlist
Hi, I want to get a latest video from Youtube Playlist. I look it on Google API, and the other solutions, but I think dont undestand quit good what I need to do. For example a have a playlist: https://www.youtube.com/playlist?list=PLW8l7rX2YaXkaSI8GGbmqPjOEmfzd2hz3 And I want to see always only a latest uploaded video, so I need a link (embed - watch, or "youtu.be/xy"): https://www.youtube.com/watch?v=LyzziLETNUw&list=PLW8l7rX2YaXkaSI8GGbmqPjOEmfzd2hz3 Thanks in advanced, T Similar Tutorialshello guys i am a newbie want help with how to upload a youtube in your script and in database i know about the $_files thing but how do i give a link please help me out !! Hi, Thanks in advance, I want to update youtube videos. here is my code. let me tell you firstly, i am very new to php. public function updateVideo($title,$description) { $title="Hello"; $description="Updating video info"; $result=$this->clientLoginAuth($this->username,$this->pass); //$fdata = file_get_contents($fullFilePath); $tmpdata = '<?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <media:group> <media:title type="plain">'.$title.'</media:title> <media:description type="plain">'.$description.'</media:description> <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category><media:keywords>Breathe Parkour Magazine</media:keywords> </media:group> <yt:accessControl action="comment" permission="allowed"/> <yt:accessControl action="commentVote" permission="allowed"/> <yt:accessControl action="videoRespond" permission="allowed"/> <yt:accessControl action="rate" permission="allowed"/> <yt:accessControl action="list" permission="allowed"/> <yt:accessControl action="embed" permission="allowed"/> <yt:accessControl action="syndicate" permission="allowed"/> </entry> '; $url = 'http://gdata.youtube.com/feeds/api/users/breathparkour/uploads/6yStkCdeLEU'; //echo $url; $data = '--f93dcbA3 Content-Type: application/atom+xml; charset=UTF-8 '.$tmpdata.' --f93dcbA3 Content-Type: video/quicktime'; //echo $data; return $this->make_update_request($url,$data); } public function make_update_request($url,$data){ //echo $url; $token = $this->accessToken; $developerKey = $this->developerKey; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($this->authType == 'GoogleLogin') $curlheader[0] = "Authorization: ".$this->authType." auth=\"$token\""; else $curlheader[0] = "Authorization: ".$this->authType." token=\"$token\""; $curlheader[1] = "X-GData-Key: key=\"$developerKey\""; $curlheader[2] = "Host: gdata.youtube.com"; $curlheader[3] = "Content-Type: application/atom+xml"; $curlheader[4] = "Content-Length: ".strlen($data); $curlheader[5] = "GData-Version: 2"; curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheader); //curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_PUT, true); $output = curl_exec($ch); curl_close($ch); print_r($output); $validresult = $this->checkErrors($output); print_r($validresult); //echo $output; if($validresult['is_error'] == 'No') { unset($validresult); return "Success"; } else { $result = array(); $result['is_error'] = $validresult['is_error']; $result['error'] = $validresult['error']; unset($validresult); return $result; } } i am getting this error. GDataParseExceptionPremature end of file Please help me. i have spent almost 6 hours on this issue. Pleazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzz I can search for videos by keyword and can fetch videos list from youtube using its api in php. I can fetch video title, description, thumbnail etc. but how can i fetch video url not like this -> youtube.com/watch?id=xyz...
Example: ytpak[dot]com
Hello, I embed some YouTube videos on my site. Sometimes a video is deleted from YouTube and I have no way of knowing. Does anyone know if there is some php script or by using their API you can check if a video has: - video has been removed - video is not embeddable any more any ideas? Thanks /df I'm not sure if this is possible
Previously I had a problem of outputting rows of a specific query
This was the solution that was given to me
$txt .= $date . " " . $stratoparse . "\n\n";Where a while loop's results were concatenated to a single string What I would like to do is output the results in individual containers with controls such as dragging for repositioning / an x for deletion That's not what I'm here for in this post I want to embed youtube videos, so they are not just stored as links, rather a clickable video so if you have something like string.string2.string3.string4.string5.<iframe src="youtube"...>.string7.string8 how would that video be isolated and parsed / understood as a front end youtube video ? To provide a brief background in case you are wondering why in my right mind, I would want to do this... First it is the primary solution that comes to mind going off what already works Secondly, the purpose or point of the concatenated string comes from the "application" design which is a store and recall interface. Vague, I know. The website has multiple users and they all have access to a single database. They save random strings, whether they are paragraphs or links, possibly videos that are uploaded, etc... these are saved by a keyphrase, later recalled by searching that keyphrase. Currently the output is nothing more than a concatenated string, that was fine initially but some of my friends have been testing the website and they made suggestions which are good such as repositioning and deleting entries. Now I want to automatically parse youtube links into embedded videos... I'll probably use that explode "function" to disect the link and place the url within the src=" " Anyway, I have to look into this but if anyone has any thoughts I'd appreciate it. Edited by moose-en-a-gant, 11 January 2015 - 02:05 AM. I have a video system on my website that allows users to post videos and it embeds youtube videos into the site, I would like to create an interface where you can comment on the actual video itself and it go to youtube's commenting stream. Is that possible? difficult? Hello everyone I am working on a blog system. and I am having problems with the youtube video embed I have found some script online that kinda works If I post more then one youtube link the player shows up.. but it says movie not loaded. if I post just one video it just shows the url to the video on youtube. here is my youtube_function.php <?PHP //convert youtube links into embede function show_youtube($text) { $VID_WID = 320; $VID_HEI = 240; for ($k=0; $k<9; $k++) { $text .= ""; $find = 'youtube.com/watch?v='; $pos = strpos($text, $find); if ($pos == false) { break; } $len = strlen($text); for ($i=$pos; $i>=0; $i--) { if (substr($text, $i, 6) == 'http://') { $pos1 = $i; break; } } for ($i=$pos; $i<$len; $i++) { if (in_array($text[$i], array('&', ' ', "\r", "\n", ',', "\t"))) { $pos2 = $i; break; } } $link1 = substr($text, $pos1, $pos2 - $pos1); $link2 = str_replace('/watch?v=', '/v/', $link1); $embed = '<object width="' . $VID_WID . '" height="' . $VID_HEI . '">'. '<param name="movie" value="' . $link2 . '"></param>'. '<param name="allowFullScreen" value="true"></param>'. '<param name="allowscriptaccess" value="always"></param>'. '<embed src="' . $link2 . '" type="application/x-shockwave-flash" '. 'allowscriptaccess="always" allowfullscreen="true" '. 'width="' . $VID_WID . '" height="' . $VID_HEI . '"></embed></object>'; $text = str_replace($link1, $embed, $text); } return $text; } ?> and I have index.php <?php session_start(); include ("includes/includes.php"); include ("includes/youtube_function.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <link rel="stylesheet" href="includes/style.css" type="text/css" media="screen" title="no title" charset="utf-8"> <title>Simple Blogging System</title> </head> <body> <div id="wrap"> <div id="header"><h1>Simple Blogging System<br /><font size="6">*Keep it simple*</font></h1></div> <div id="nav"> <center> Link Link Link </center> </div> <div id="main"> <div id="blogPosts"> <?php $blogPosts = GetBlogPosts(); foreach ($blogPosts as $post) { echo "<div class='post'>"; echo "<h2>" . $post->title . "</h2>"; echo show_youtube($post->post, $text); echo "<span class='footer'>Posted By: " . $post->author . " Posted On: " . $post->datePosted . " Tags: " . $post->tags . "</span>"; echo "</div>"; ?> <br /> <?php } ?> </div> </div> <div id="sidebar"> <h2>Archive</h2> <p> old </p> <p> old </p> <p> old </p> </div> <div id="footer"> <p>Simple Blogging System</p> </div> </div> </body> </html> so as you can see I have show_youtube($post->post, $text); I have tried this just out of curiosity to see if I could fix this myself. but It seems like the video does not want to run at all... I am confused with this and some help would be greatly appreciated. Thank you in advance Hi guys, In an application I'm working on, I'm looking to embed a youtube video with [YOUTUBE][/YOUTUBE]. Code: [Select] echo preg_replace('#(?:<\>]+href=\")?(?:http://)?((?:[a-zA-Z]{1,4}\.)?youtube.com/(?:watch)?\?v=(.{11}?))[^"]*(?:\"[^\<\>]*>)?([^\<\>]*)(?:)?#', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'.$matches[2].'"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'.$matches[2].'" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $ENTIREPAGE?); The problem is that the video appears with a slider control at the bottom. How do I get rid of the Youtube slider control at the bottom? Thanks. Anyone have access to a youtube video/audio downloader script? I'm sure there are one of these laying around somewhere... Looking for 1. I am looking for a code where I can get a video URL from Youtube, Vimeo, Facebook and convert it to an embedded video to be shown on my site. I found a script that does that. It works fine. The only errors I get are in the inspect element window in the browser. Errors such as this. Failed to load resource: net::ERR_BLOCKED_BY_CLIENT googleads.g.doubleclick.net/pagead/id:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT static.doubleclick.net/instream/ad_status.js:1
This is the function to generate the embedded videos. Do the above errors matter if the videos show up and play fine? function generateVideoEmbedUrl($url){ //This is a general function for generating an embed link of an FB/Vimeo/Youtube Video. $finalUrl = ''; if(strpos($url, 'facebook.com/') !== false) { //it is FB video $finalUrl.='https://www.facebook.com/plugins/video.php?href='.rawurlencode($url).'&show_text=1&width=200'; }else if(strpos($url, 'vimeo.com/') !== false) { //it is Vimeo video $videoId = explode("vimeo.com/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://player.vimeo.com/video/'.$videoId; }else if(strpos($url, 'youtube.com/') !== false) { //it is Youtube video $videoId = explode("v=",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else if(strpos($url, 'youtu.be/') !== false){ //it is Youtube video $videoId = explode("youtu.be/",$url)[1]; if(strpos($videoId, '&') !== false){ $videoId = explode("&",$videoId)[0]; } $finalUrl.='https://www.youtube.com/embed/'.$videoId; }else{ //Enter valid video URL } return $finalUrl; }
How could I from the varying URLs parse only the YouTube video ID? http://www.youtube.com/watch?v=SwrawcORlp0&feature=player_embedded http://www.youtube.com/watch?v=SwrawcORlp0&feature=popular How can I from the URLs above only extract the id into a variable $url SwrawcORlp0 Thanks, df This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348054.0 I need PHP script that will parse XML-based (.xspf format) live stream playlist stored on web server, retrieve track data and print it on my web page. Print inside div as scrolling text (one line). The track data on page need be refreshed synchronously to show current track info. XSPF playlist example: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <playlist xmlns="http://xspf.org/ns/0/" version="1"> <title/> <creator/> <trackList> <track> <location>http://geodesid5.streams.audioveduct.com:80/di_ambient7</location> <title>Bruno Sanfilippo - Piano Textures 2 II</title> <annotation>Stream Title: Ambient - DIGITALLY IMPORTED - a blend of ambient, downtempo, and chillout Content Type:audio/mpeg Current Listeners: 0 Peak Listeners: 0 Stream Gen Electronic Ambient Downtempo</annotation> <info>http://www.di.fm</info> </track> </trackList> </playlist> I need get data from fields 'title' and 'annotation' (only text between Stream Title and Content Type). Also, after these two, I want scroll small custom text, when required. I searched some close example, but didn't find yet. Will be DOMDocument method suitable for this task? Can someone show me the right method to do this? hey I am not usually in this php forum, I am usually around html/css but a task arose and I figure since this forum uses smf it would be a perfect place to ask. Not saying you are all smf experts though. My question is how do I display the latest posts for smf in a page thats not a forum page. Like On my index page I want to display the latest posts on the forum. Help anyone? Right now I just cheated and sorted by descending then put like thirty <br />'s so you couldn't see old ones. How can I do this properly? I am bit confused. Can we display the latest tweet in the webpage. I'm having trouble listing the most recent 10 content. How can I solve this problem. $sorgu = mysqli_query("select * from icerik order by id desc limit 0,10");
while($goster=mysqli_fetch_assoc($sorgu)) { } error code: Fatal error: Uncaught ArgumentCountError: mysqli_query() expects at least 2 arguments, 1 given in C:\xampp\htdocs\blog\orta.php:3 Stack trace: #0 C:\xampp\htdocs\blog\orta.php(3): mysqli_query('select * from i...') #1 C:\xampp\htdocs\blog\index.php(4): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\blog\orta.php on line 3 I'm in the process of creating a webage that shows latest scores and an updated league table for soccer/football matches like the bbc sports website does. I have the database set up with a form to update and display latest score all work well apart from if i update a score like the following teamA 1 teamB 0 it updates table to give teamA 3 points based on the current score however if teamA score again teamA 2 teamB 0 it updates table again but gives teamA another 3 points which is not correct so i need a way to stop it happening. thought about it for a while and only thing i can come up with is some maths to compare the values of score for each team and add/remove points as dependent on current score. Anyone got something similar to this Hello all, My question is about a custom-coded latest-news plugin written by someone else. I don't know if it is generic, a copy of something else or what. It works good! but when I go to add a new news item to the list under Settings, it adds the item to the bottom of the list. The news is displayed on my homepage in short form and in full format on the primary news page. I need new items to be added to the TOP of the list instead or in reverse, so that in all the containers where it resides, the latest news item added is always at the top of the list. I know nothing about php but I am looking to learn. I plan on taking some basic classes on css and php to upgrade my archaic html skills, but I'm currently studying other subjects. Regardless, if this has a simple fix, I would be very interested in knowing what is needed and where/why. Here is the core of the php that I am finding in the plugin: There are three php files, This one says active, the other two say inactive so I get the impression they are not in use. Let me know if I should post their contents as well. Appreciate any help with this! My sincere thanks in advance. Labeled active: latest_news.php */ob_start();register_activation_hook(__file__, latest_news_install);function latest_news_install() { global $wpdb; $table_name = $wpdb->prefix . "latest_news"; if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " ( `id` int(10) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `description` text NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );"; mysql_query($sql) or die(mysql_error()); }}if( !function_exists('wp_latest_news_init') ) { function wp_latest_news_init() { add_shortcode( 'wp_latest_news', 'shortcode_latest_news'); }}if( !function_exists('shortcode_latest_news') ) { function shortcode_latest_news() { // extract(shortcode_atts(array('limit' => '5', ), $atts)); global $wpdb; $user_count = $wpdb->get_results("SELECT * FROM wp_latest_news ORDER BY date ASC LIMIT 4"); foreach ($user_count as $output) { $htmlOutput[] = "<li><b><a href='". get_permalink(287)."?news_id=".$output->id."'>" . $output->title . "</a></b></li>"; } //echo $htmlOutput; //echo "<pre>"; print_r($user_count); echo "</pre>"; foreach ($htmlOutput as $out) { echo $out; } return $htmlOutput; }}/* add_action('init', 'wp_latest_news_init' ) is used for call init function for create shortcode */add_action('init', 'wp_latest_news_init' );add_action('admin_menu', 'wp_latestnews_links' );function wp_latestnews_links() { add_submenu_page( 'options-general.php', __( 'Latest News ' ), __( 'Latest News ' ), 5 , 'latest_news_settings', 'latest_news_settings' );}// function latest_news_settings() {// global $wpdb;// if (isset($_POST["submit"])) {// $sql="INSERT INTO ".$wpdb->prefix . "latest_news(`title`,`description`) VALUES ('".$_POST['news_title']."','".$_POST['description']."') ";// //$sql=$wpdb->insert( $wpdb->latest_news, array( 'title' => $_POST['news_title'] ,'description' => $_POST['description'] ) );// mysql_query($sql) or die(mysql_error());// }// include 'Latest_news_setting.php';function latest_news_settings() { global $wpdb; $action = $_REQUEST["action"]; $id = $_REQUEST['id']; $sql = "SELECT * from ".$wpdb->prefix."latest_news "; $results = $wpdb->get_results($sql); //echo "<pre>";print_r($results); //$post_arr = query_posts(""); //echo "<pre>";print_r($post_arr);exit; switch ($action) { case 'add' : include('news_form.php'); break; case 'save' : if(isset($_POST['cancel'])) { include('latest_news_list.php'); } else if(isset($_POST['add'])) { $wpdb->query("insert into ".$wpdb->prefix."latest_news (`title`,`description`) VALUES ('".$_REQUEST['news_title']."','".$_REQUEST['description']."')"); //header("Location: http://localhost:81/Bravo/wp-admin/edit.php?page=slider_images"); header("location:?page=latest_news_settings"); } break; case 'edit' : $sql = "SELECT * from ".$wpdb->prefix."latest_news where id = '".$id."' "; $results_arr = $wpdb->get_results($sql); //echo "<pre>";print_r($results_arr); include('news_form.php'); break; case 'update' : if(isset($_POST['cancel'])) { include('news_form.php'); } else if(isset($_POST['edit'])) { //echo $id; $wpdb->query("update ".$wpdb->prefix."latest_news set title = '".$_REQUEST['news_title']."', description = '".$_REQUEST['description']."' where id='".$id."'"); header("location:?page=latest_news_settings"); } break; case 'delete' : $wpdb->query("delete from ".$wpdb->prefix."latest_news where id='".$id."'"); header("location:?page=latest_news_settings"); break; default: include('latest_news_list.php'); break; }}?>() Hi Guys, Sorry if this is the wrong forum but i wasnt sure the best one. i am trying to see how others control the version of apps they have written and updating. i want to set the version of my app e.g. 1.0 and then have a section where if i release 1.5 it will show up that a new version is available for upgrade. the only thing im not too sure about is when someone goes to upgrade if not all of the updated files are uploaded correctly i want it to say version missmatch. could someone give me examples of how i could achieve this? |