Video's uit youtube feed
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
}
?>
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
}
?>
Deze keer heb ik hem voor je aangepast, maar zou je voortaan zelf een betere topic titel willen verzinnen?
[/modedit]
Gewijzigd op 18/06/2011 19:52:06 door Niels K
krijg je een error? wat loopt er mis?
Code (php)
1
2
3
2
3
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
word de video id niet weergeven waardoor in het iframe de 404 pagina van YouTube verschijnt.
dus getVideoID($article['link']) weergeeft niks?
Ja
En je had je vraag beter in je bestaande topic (met hetzelfde probleem) kunnen plaatsen.
Hier de volledige code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article["link"] = $item->link);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
}
?>
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article["link"] = $item->link);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
}
?>
Nog een vraag, weet iemand toevallig hoe ik een maximum aantal items wat worden weergegeven kan instellen?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//Aantal items wat je wil laten zien
$count = 10;
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
$i = 1;
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
if($i == $count) break;
$i++;
}
?>
//Aantal items wat je wil laten zien
$count = 10;
$articles = array();
$blog_url = "http://gdata.youtube.com/feeds/base/users/remcob00/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile";
$rawFeed = file_get_contents($blog_url);
$xml = new SimpleXmlElement($rawFeed);
$channel = array();
$channel["title"] = $xml->channel->title;
$channel["link"] = $xml->channel->link;
$channel["description"] = $xml->channel->description;
$channel["pubDate"] = $xml->pubDate;
$channel["timestamp"] = strtotime($xml->pubDate);
$channel["generator"] = $xml->generator;
$channel["language"] = $xml->language;
function getVideoID($string = '') {
$parsed_url = parse_url($string, PHP_URL_QUERY);
if($parsed_url) {
parse_str($parsed_url, $parsed_str);
return $parsed_str['v'];
}
return false;
}
$i = 1;
foreach ($xml->channel->item as $item)
{
$article = array();
$article["channel"] = $blog_url;
?>
<ul>
<li><h2> <?php echo $article["title"] = $item->title;?></h2>
<iframe width="425" height="349" src="http://www.youtube.com/embed/<?php
echo getVideoID($article['link']);
?>" frameborder="0" allowfullscreen></iframe>
<?php echo $article["description"] = (string) trim($item->description);?>
</li>
</ul>
<?php
if($i == $count) break;
$i++;
}
?>
Thanks