PHP - Embedding A Youtube Video Within A Concatenated String
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. Similar Tutorialshere i am again... so i have this algorithm that computes the current academic year for our school.. it outputs the correct academic year on a browser.. but when i try to insert it into my database, the data inserted goes wrong.. it just keeps on inserting -1 instead of the string 2011-2012 here's my code: Code: [Select] <?php $year = date('Y'); $currentyear = $year; $lastyear = $year - 1; $nextyear = $year + 1; if (date('m') < 6) { $current_ay = $lastyear."-".$currentyear; } else if (date('m') >= 6) { $current_ay = $currentyear."-".$nextyear; } echo $current_ay; $insertSQL = "INSERT INTO tbl_elections (election_id) values ($current_ay)"; mysql_select_db($database_organizazone_db, $organizazone_db); $Result1 = mysql_query($insertSQL, $organizazone_db) or die(mysql_error()); ?> *the database column to be inserted into is of varchar data type hello 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 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 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 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 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; }
Hello, Anyone know a way I could extract information from YouTube. If I have the URL for the video, how could I get the title, runtime, tags and so on into different strings? url = "http://www.youtube.com/watch?v=kMAI26FPeyM"; Thanks Hello. I have a simple enough code that takes information from one table and drops it into another. This is great, but I have 2a new complexities that I have been unable to code correctly. A. 'lastname', 'firstname' on table1 need to be combined into 'name' How & Where do I combine these strings and then pass them? Code: [Select] <?php include('dbconfig.php'); // Make a MySQL Connection mysql_connect("localhost", "$user", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); $result = mysql_query( "INSERT INTO table2 (lastname, firstname, email) SELECT lastname, firstname, email FROM table1 WHERE email='someemail@gmail.com' ") or die(mysql_error()); ?> This is a LINK to the page -> http://shoutkey.com/carriage I have a problem of separating MySQL concatenated info, yet still maintaining their relationship to other arrays in the same order. First off here is the MySQL code: Code: [Select] $query ="SELECT report,"; $query.="GROUP_CONCAT(DISTINCT docID) AS docIDs, "; $query.="GROUP_CONCAT(DISTINCT analyst) AS analysts, "; $query.="GROUP_CONCAT(DISTINCT region) AS regions, "; $query.="GROUP_CONCAT(DISTINCT country) AS countries, "; $query.="GROUP_CONCAT(DISTINCT topic) AS topics, "; $query.="GROUP_CONCAT(DISTINCT date) AS dates, "; $query.="GROUP_CONCAT(DISTINCT event) AS events, "; $query.="GROUP_CONCAT(DISTINCT link) AS links, "; $query.="GROUP_CONCAT(DISTINCT province) AS provinces "; $query.="FROM reports GROUP BY report ORDER BY dates DESC, docIDs DESC"; The most important thing is to get all attributes about each report. The thing is, each report can have as many records as it must, in order to store various types of information, like, if multiple analysts are working on the report, then each one saves their own record, but when retrieving these records MYSQL concatenates the records, to make it look to the analysts like this Report 1 --- Josh, Rebecca --- Philippines However, my problem is trying to display the reports by country... as you can see http://shoutkey.com/carriage. I have no idea about how to split up the countries, while maintaining their relationship to the $rows pulled from MySQL. I am gonna post the entire code, and let me know if anybody has any ideas. Code: [Select] $result = mysql_query($query); $numrows = mysql_affected_rows(); $current = false; while($row=mysql_fetch_assoc($result)) { $dates = $row['dates']; $analysts = $row['analysts']; $provinces = $row['provinces']; $topics = $row['topics']; $regions = $row['regions']; $countries = $row['countries']; $reports = $row['report']; $links = $row['links']; $events = $row['events']; if (!$current){ //first call echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo first call $current = $countries; echo "<div>" ;//open content div } elseif($current != $countries){ // country has changed echo "</div>"; //close previous content div echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo subsequent countries $current = $countries; echo "<div><p>" ;//open content div } echo $analysts." ----- ".$provinces." ----- ".$reports; echo "<br /><br />"; } echo "</div>"; ?> </div> 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 I'm trying to Embed the images from Apple into my PHP file. Code: [Select] $phpobj = unserialize($response); if (is_array($phpobj)) { foreach ($phpobj['value']['items'] AS $key => $val) { printf("<div><p><a href=%s>%s</a></p><p>%s</p>\n", $val['link'], $val['title'], $val['description']); } } But the problem is that the image attribute is inside a Table and using something lile $val['img'] is not working. So anybody can help me with this. Here is the RSS feed format from which I'm importing Code: [Select] <item> <title>Dead Awake - Trailer</title> <link>http://trailers.apple.com/trailers/independent/deadawake/</link> <description>DEAD AWAKE is a seductive supernatural thriller starring Rose McGowan, Amy Smart and Nick Stahl set against the backdrop of a mysterious tragedy that shattered their lives a decade ago and which sets them on a path to uncover the truth that lies between the living and the dead.</description> <pubDate>Wed, 01 Dec 2010 00:00:00 PST</pubDate> <content:encoded><![CDATA[ <table> <tr valign="top"> <td width="67"><a href="http://trailers.apple.com/trailers/independent/deadawake/"><img src="http://trailers.apple.com/trailers/independent/deadawake/images/poster.jpg" width="65" height="97" border="0"></a></td> <td> </td> <td><a href="http://trailers.apple.com/trailers/independent/deadawake/"><span style="font-size: 16px; font-weight: 900; text-decoration: underline;">Dead Awake - Trailer</span></a><br /> <span style="font-size: 12px;">DEAD AWAKE is a seductive supernatural thriller starring Rose McGowan, Amy Smart and Nick Stahl set against the backdrop of a mysterious tragedy that shattered their lives a decade ago and which sets them on a path to uncover the truth that lies between the living and the dead.<br /><b>Directed by:</b> Omar Naim<br /><b>Starring:</b> Nick Stahl, Rose McGowan, Amy Smart, Ben Marten, Kim Grimaldi, Brian Lynner, Justin Marxen, James Serpento, Jack Mishler, Shane Simmons, Rachel Storey, Justin Urich, Andrea Leon, Livia Milano, Phyllis Mumford</span></td> </tr> </table> ]]></content:encoded> </item> i want to change the content of my div tag dynamically using javascript in PHP. I am using the following technqiue but it is not working. <?php echo "<script type='text/javascript'>\n"; echo "document.getElementById('mydiv').innerHTML = 'contents of div.......';"; echo "</script>"; ?> please guide me how can i do this Thanks, Best Regards, Nice Candy. HI I am trying to find solutions on how i am able to embed IP Screenshots into a website. Right now i am able to do so but only if i am connected to a certain internet network, then i would be able to see those IP Screenshots images. However if i am not connected to that network, the website are not able to show them. THANKS ALOT!! OK, I've seen this done both ways and want to know which (if any) is the most secure way to do it... I've been coding my pages using echo statements to write HTML, such as: <?php echo "<p><strong>hello, World!</strong></p>"; echo "<p>You a $age year(s) old!</p> "; ... ?> and so on... but is this any better <?php <p><strong>Hello World!</strong></p> echo "<p><strong>You are $age year(s) old!</p>"; ?> Is one of these methods better than the other (using ECHO to write actual HTML statements out rather than just embedding them in the script without ECHO)? Which is the recommended method? Hello. I've asked around in many places now, and I thought I'd ask here too. A few days ago I installed phpBB3 on my site, works like a charm. I used a plugin for wordpress to integrate phpbb to wordpress, all works great. Now my problem is to embed the forum to my wordblog page. I tried using a simple iFrame solution, and it worked almost, but there's a common iFrame problem. The height, it doesn't scale with the embedded page, instead it stays as a 100px high frame with a scroll bar. I've searched google for hours now, and tried every possible javascript and css/div-tag solution I came across. Nothing works. Are there any alternatives to this? I tried using <?php include('../phpBB3/index.php') ?> But I get errors. It might be because I'm including from another directory, so it might be worth giving a try to give the direct path somehow, but how? Anyway, are there any other solutions for this problem? |