Merge pull request #2654 from icecaster/patch-3

Fixed RSS example
This commit is contained in:
Ingo Schommer 2013-11-18 08:22:50 -08:00
commit f59c47fd8e

View File

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