Fixed RSS example

This commit is contained in:
Tim 2013-11-12 10:50:27 +13:00
parent b5b8cb25e0
commit e2238245b9

View File

@ -150,18 +150,19 @@ Put something like this code in mysite/code/Page.php inside class Page_Controlle
:::php
// Accepts an RSS feed URL and outputs a list of links from it
public function RestfulLinks($url){
$delicious = new RestfulService($url);
$conn = $delicious->connect();
$result = $delicious->getValues($conn, "item");
$service = new RestfulService($url);
$request = $service->request();
$body = $request->getBody();
$items = $service->getValues($body,"channel","item");
$output = '';
foreach ($result as $key => $value) {
foreach($items as $item) {
// Fix quote encoding
$description = str_replace('"', '"', $value->description);
$output .= '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>';
$description = str_replace('&amp;quot;', '&quot;', $item->description);
$output .= "<li><a href=\"{$item->link}\">{$item->title}</a><br />{$description}</li>";
}
return $output;
}
}
Put something like this code in `themes/<your-theme>/templates/Layout/HomePage.ss`:
@ -174,4 +175,4 @@ Put something like this code in `themes/<your-theme>/templates/Layout/HomePage.s
## API Documentation
`[api:RestfulService]`
`[api:RestfulService]`