×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Example Syndication Service in WidSets

From Nokia Developer Wiki
Jump to: navigation, search
tanjaluodes (Talk | contribs)
m
hamishwillee (Talk | contribs)
m (Bot fixing redirect link)
Line 1: Line 1:
 
{{Archived}}[[Category:WidSets]][[Category:Code Examples]]
 
{{Archived}}[[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://digg.com/ www.digg.com] RSS feed.
  
 
''syndication_service.he''
 
''syndication_service.he''
Line 71: Line 71:
 
     <parameter name="widgetname">Syndication Service</parameter>
 
     <parameter name="widgetname">Syndication Service</parameter>
 
     <parameter type="url" name="url" editable="false">
 
     <parameter type="url" name="url" editable="false">
       <value>http://www.digg.com/rss/index.xml</value>
+
       <value>http://digg.com//rss/index.xml</value>
 
     </parameter>
 
     </parameter>
 
   </parameters>
 
   </parameters>

Revision as of 14:29, 26 May 2011

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

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://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>
43 page views in the last 30 days.
×