BjoJn
Legacy Member
Ik heb een scriptje die zou moeten een Picasa rss parsen op een website. Ik heb zelf het begin geschreven en heb beroep gedaan op een bestaand scriptje om de afbeelding weer te geven.
Echter, krijg ik een stomme error in php
Warning: Invalid argument supplied for foreach() in /customers/fclindeblomme.be/fclindeblomme.be/httpd.www/rss/rsstest.php on line 11
Blijkbaar zie ik een dom argument over het hoofd, maar ik zie het echt niet..
Echter, krijg ik een stomme error in php
Warning: Invalid argument supplied for foreach() in /customers/fclindeblomme.be/fclindeblomme.be/httpd.www/rss/rsstest.php on line 11
Blijkbaar zie ik een dom argument over het hoofd, maar ik zie het echt niet..
PHP:
<?php
// XML naar $url
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$xml = simplexml_load_string($response);
// Rss titel
foreach ($xml->channel as $item){
echo "<h2><a href=\"".$item->link."\">".$item->title." ></a></h2>\n";
}
$items = $xml->channel;
echo "<ul>\n";
foreach ($items->item as $item){
$title = $item->title;
$content = $item->description;
// Afbeelding weergeven
$quotes = array('"', "'", "\n");
$imgContents = str_replace($quotes, '', $content); // Strip " , ' en \n
$imgContents = stristr($imgContents, 'src='); // 'src'
$endTagPosition = stripos($imgContents, 'alt'); // end tag '>'
$img = substr($imgContents, 4, $endTagPosition - 4); // 'src="path"'
// Swap afbeeldingen
$img144 = str_replace('/s288', '/s144', $img);
$img800 = str_replace('/s288', '/s800', $img);
?>
<li>
<a href="<?php echo $link; ?>">
<img src="<?php echo $image; ?>" alt="<?php echo $title; ?>" />
</a>
</li>
<?php
}
echo "</ul>\n";
$picsid = "svw20092010";
$pics = 6;
$url = "http://picasaweb.google.com/data/feed/base/user/". $picsid ."?kind=album&alt=rss&hl=en_US&access=public&max-results=". $pics ."";
?>
daarom kom ik dit hier even vragen 