/    Sign up×
Community /Pin to ProfileBookmark

Postin my latest few youtube videos?

I don’t know if this is the right section for this, so sorry if it’s not.

I found this simple script for having my latest tweet on my site:
[url]http://www.webdesigndev.com/programming/how-to-display-your-last-tweet-using-javascript-and-the-twitter-api[/url]

And I was wondering if youtube had a similar feature, where I could have the thumbnails and links to my last few youtube videos on my site.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@donatelloApr 24.2010 — Screenscrape it with PHP.

[code=php]
<html>
<head>
<title>Your Youtube Videos ScreenScraper</title>
</head>
<body>
<?php

$page = file_get_contents("http://www.youtube.com/user/InternationalCaller#p/u");
//Your YouTube user name would go there instead of mine!//
//Above this line, ALL WORKS FINE! ////////////////////////////////////////////////////

// FOR you the $getpage should be the entire html you display on the page
$explodefirst = explode('<div class="scrollbox-body">',$page);
$headerisgone = $explodefirst[1];
$explodesecond = explode('<div class="scrollbox-separator">',$headerisgone);
$endresult = $explodesecond[0];

//You can use str_replace to change style elements, link base urls, etc.
/*
$endresult = str_replace('bgcolor="#2b4c3f"','', $endresult);
$endresult = str_replace('width="325"','width="345"', $endresult);
*/
$endresult = str_replace('href="/','target="_blank" rel="nofollow" href="http://www.youtube.com/', $endresult); //setting links to open in new window, nofollow and base YouTube.

print '<div class="scrollbox-body">'; //putting back the DIV we removed in the first function
print $endresult;
print '<p>&nbsp;</p>';
?>
</body>
</html>
[/code]


I tested it and it works. ?

You can get the general idea and tinker with it to show your latest vids.

You can copy the elements you need from the Youtube stylesheet, and use my str_replace to reset the correct URLs, etc.
×

Success!

Help @memzenator spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...