Archive for October 2009
3
Youtube Profile to Website Tutorial in 12 easy steps
9 Comments | Posted by Cliff in Website Tutorials
I just got the youtube profile loader working on Faith Family Jesus and I would like to share with you how you can do it very easily with just 4 paste operations. I hope to have the youtube interface working for all of the churches on the faith family jesus site in the next few weeks. I should have the Twitter, and Google Calendar API’s working soon also with tutorials so please subscribe!
If you want to put your youtube videos on your own website it’s pretty easy, but you are gonna need a few things.
1. web hosting with php 5
2. Download Zend framework with Gdata module http://framework.zend.com/download/gdata I used version 1.9.3PL1
3. Unzip and upload to your server keeping the folder named ZendGdata-1.9.3PL1
4. Get a developer key http://code.google.com/apis/youtube/dashboard/gwt
5. goto the folder at ZendGdata-1.9.3PL1/demos/Zend/Gdata/YouTubeVideoApp and create a new php file called testyoutube.php
copy and paste the following into the file
<?php session_start();
set_include_path(’.’ . PATH_SEPARATOR . dirname(__FILE__) . ‘/ZendGdata-1.9.3PL1/library’);
require_once ‘Zend/Loader.php’;
$_SESSION['developerKey'] = ‘PASTE YOUR KEY HERE’;
function uploadStatus($status, $code = null, $videoId = null)
{
switch ($status) {
case $status < 400:
echo ‘Success ! Entry created (id: ‘. $videoId .
‘) <a href=”#” onclick=” ytVideoApp.checkUploadDetails(\”.
$videoId .’\'); “>(check details)</a>’;
break;
default:
echo ‘There seems to have been an error: ‘. $code .
‘<a href=”#” onclick=” ytVideoApp.checkUploadDetails(\”.
$videoId . ‘\’); “>(check details)</a>’;
}
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<title>Youtube Test</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<link href=”video_app.css” type=”text/css” rel=”stylesheet” />
<script src=”video_app.js” type=”text/javascript”></script>
</head>
<body>
<div id=”searchBox”>
<script>guy = ytVideoApp.listVideos(’search_username’, ‘aboutbiblevideos’, 1);</script>
</div>
<div id=”searchResultsListColumn”>
<div id=”searchResultsVideoList”></div>
<div id=”searchResultsNavigation”>
<form id=”navigationForm” action=”javascript:void();”>
<input type=”button” id=”previousPageButton” onclick=”ytVideoApp.listVideos(ytVideoApp.previousQueryType, ytVideoApp.previousSearchTerm, ytVideoApp.previousPage);” value=”Back” style=”display: none;” />
<input type=”button” id=”nextPageButton” onclick=”ytVideoApp.listVideos(ytVideoApp.previousQueryType, ytVideoApp.previousSearchTerm, ytVideoApp.nextPage);” value=”Next” style=”display: none;” />
</form>
</div>
</div>
<div id=”searchResultsVideoColumn”>
<div id=”videoPlayer”>
<script>
ytVideoApp.presentVideo(’oWHHrRs_0gw’);
// copy and paste the v param to the end or until the &
// ie http://www.youtube.com/watch?v=oWHHrRs_0gw
</script>
</div>
</div>
</body>
</html>
6. on line 3 above paste your key over PASTE YOUR KEY HERE, at the bottom of the file where it says
ytVideoApp.presentVideo(’oWHHrRs_0gw’);
paste your default video id, instead of oWHHrRs_ogw which is About Bible Videos series The Book of Revelation chapter 1. You can find the id on the URL of your youtube video, it will be the v=something paramater of the URL
7. save the file and upload the file along with all of the other files in the YouTubeVideoApp folder to the main folder on your website (make sure you can see the folder ZendGdata-1.9.3PL1 when you upload the files)
8. open the page on your favorite web-browser to make sure it works correctly
9. For most youtube profile’s you would be done right now, but many good videos use URL sources for their video descriptions. To fix long URLS without using TinyURL or another service and still keep long strings of text from running over into other div columns, open the file operations.php in the YouTubeVideoApp folder
10. goto line 686 where it says (if you don’t have an editor with line numbers, copy, paste, and search for the line below)
$videoTags = $entry->getVideoTags();
and paste the following immediately after the line above
// long url fixer
$newvidguy = ”;
$vidlenguy = strlen($videoDescription);
$newvidcnt = 0;
$spacecnt =0;
while($newvidcnt < $vidlenguy)
{
$bytex=substr($videoDescription,$newvidcnt,1);
if($bytex!= ‘ ‘)
{
}
else
{
$spacecnt = 0;
}
if($spacecnt > 50)
{
$newvidguy = $newvidguy . chr(13)’;
$spacecnt=0;
}
$newvidguy = $newvidguy . $bytex;
++$spacecnt;
++$newvidcnt;
}
$videoDescription = $newvidguy;
11. Goto line 846 where it says (if you don’t have an editor with line numbers, copy, paste and search for the line below)
$description = htmlspecialchars($entry->getVideoDescription());
and paste in the following immediately after the above line
// long url fixer
$newvidguy = ”;
$vidlenguy = strlen($description);
$newvidcnt = 0;
$spacecnt =0;
while($newvidcnt < $vidlenguy)
{
$bytex=substr($description,$newvidcnt,1);
if($bytex != ‘ ‘)
{
}
else
{
$spacecnt = 0;
}
if($spacecnt > 50) // make a space after 50 chars in a row
{
$newvidguy = $newvidguy . chr(13);
$spacecnt = 0;
}
$newvidguy = $newvidguy . $bytex;
++$spacecnt;
++$newvidcnt;
}
$description = $newvidguy;
12. save and upload the operations.php file and you are done!
So in just 12 easy steps you can integrate this powerful functionality into your site
Thanks for reading!
Cliff – Faith Family Jesus
9 Comments for Youtube Profile to Website Tutorial in 12 easy steps
About Bible Videos | October 5, 2009 at 9:59 pm
Cliff | October 5, 2009 at 10:12 pm
I just shortened the provided sample code and swapped out the search form for a call to get a user’s videos, this was more for a quick tutorial to get you up and going, not really for production. When I took out the search form it must have removed some initialization . . . I’ll see if I can fix it
Calsetitefs | December 18, 2009 at 12:39 am
What’s up everyone, I’m modish to the forum and fair-minded wanted to roughly hey. hi leaning manipulate to comprehend unexplored pepole and allowance tackle with them
have a contented year
discount amazon | February 15, 2010 at 3:18 pm
interesting post. I would love to follow you on twitter.
payday loans | February 20, 2010 at 3:43 pm
I want to thank the blogger very much not only for this post but also for his all previous efforts. I found faithfamilyjesus.com to be greatly interesting. I will be coming back to faithfamilyjesus.com for more information.
account money | February 27, 2010 at 8:28 am
After reading you site, Your site is very useful for me .I bookmarked your site!
whopDordido | March 4, 2010 at 5:34 am
i very adore your own writing kind, very charming.
don’t quit and also keep penning due to the fact it simply good worth to read it,
excited to browse through much of your current posts, have a pleasant day!
whopDordido | March 26, 2010 at 8:19 pm
i really enjoy your own posting type, very remarkable.
don’t give up and keep posting considering the fact that it just that is worth to follow it.
impatient to see much more of your current web content, good bye























Everything works for me, but I get a script error in IE, do you know why?