From e2238245b9b6a547208d7794e329dc9e29e390a0 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 12 Nov 2013 10:50:27 +1300 Subject: [PATCH] Fixed RSS example --- docs/en/reference/restfulservice.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/en/reference/restfulservice.md b/docs/en/reference/restfulservice.md index 7bd175b1f..1898129d8 100644 --- a/docs/en/reference/restfulservice.md +++ b/docs/en/reference/restfulservice.md @@ -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 .= '
  • '.$value->title.'
    '.$description.'
  • '; + $description = str_replace('"', '"', $item->description); + $output .= "
  • link}\">{$item->title}
    {$description}
  • "; } return $output; - } + } Put something like this code in `themes//templates/Layout/HomePage.ss`: @@ -174,4 +175,4 @@ Put something like this code in `themes//templates/Layout/HomePage.s ## API Documentation -`[api:RestfulService]` \ No newline at end of file +`[api:RestfulService]`