×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Example Syndication Service in WidSets

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
m (Protected "Example Syndication Service" [edit=sysop:move=sysop])
Forum Nokia KB (Talk | contribs)
Line 1: Line 1:
[[Category:WidSets]]
+
[[Category:WidSets]][[Category:Code Examples]]
 
{{FNWID}}
 
{{FNWID}}
 
This script code uses the Syndication service to fetch the 10 most recent items from the [http://www.digg.com www.digg.com] RSS feed.
 
This script code uses the Syndication service to fetch the 10 most recent items from the [http://www.digg.com www.digg.com] RSS feed.

Revision as of 10:00, 16 June 2008

FNWID.gif

This script code uses the Syndication service to fetch the 10 most recent items from the www.digg.com RSS feed.

syndication_service.he

class
{
  void startWidget()
  {
    setMinimizedView(createMinimizedView("viewMini", getStyle("default")));
  }


  Shell openWidget()
  {
    fetch();
    
    return null;
  }

  
  void fetch()
  {
    //As we do not have any content yet, we want all feed items
    //since the year 1970 (usually RSS feeds contain 20-30 items).
    Value arg = [
      "ts" => 0,
      "max" => 10
    ];

    call(null, "syndService", "getItems", arg, ok, nok);
  }


  void ok(Object state, Value ret)
  {
    setBubble(null, "Got "+ret.size()+" items");
    
    //print subjects to log
    foreach (Value item : ret) {
      printf("subject: "+item.title);
    }
  }


  void nok(Object state, String error)
  {
    setBubble(null, "Syndication get failed: "+error);
  }

} //class

widget.xml

<?xml version="1.0" encoding="utf-8"?>
 
<widget spec_version="2.0">
  <info>
    <name>example_syndication_service</name>
    <version>1.0</version>
    <author>example</author>
    <clientversion>1.0</clientversion>
    <shortdescription>Syndication Service Example</shortdescription>
    <longdescription>Syndication Service Example</longdescription>
    <tags>example syndicationservice</tags>
  </info>
   
  <parameters>
    <parameter name="widgetname">Syndication Service</parameter>
    <parameter type="url" name="url" editable="false">
      <value>http://www.digg.com/rss/index.xml</value>
    </parameter>
  </parameters>

  <services>
    <service type="syndication" id="syndService">
      <reference from="url" to="feedurl"/>
    </service>
  </services>
    
  <resources>
    <code src="syndication_service.he"/>
    
    <stylesheet>
      mini {
        background: solid white;
        color: black;
        align: vcenter hcenter;
      }
      
      maxi {
        background: solid white;
        padding: 5 5 5 5;
      }
      
      flow {
        background: solid white;
      }
    </stylesheet>
  </resources>
    
  <layout minimizedheight="2em">
    <view id="viewMini" class="mini">
      <label class="mini">${widgetname}</label>
    </view>
  </layout>
 
</widget>
68 page views in the last 30 days.
×