×
Namespaces

Variants
Actions
Revision as of 08:44, 29 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Example Http Service on WidSets

From Nokia Developer Wiki
Jump to: navigation, search

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.

Article Metadata
Article
Created: User:Mirsilla (26 May 2008)
Last edited: hamishwillee (29 Jun 2012)
FNWID.gif

This script code does a HTTP GET search to Google and prints the resulting HTML content to a log.

http_service.he

class
{
  const String URL = "http://www.google.com/search";
  
  
  void startWidget()
  {
    setMinimizedView(createMinimizedView("viewMini", getStyle("default")));
  }


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

  
  void fetch()
  {
    //http parameters to be used in get-query
    Value params = [
      "q" => "widsets",
      "meta" => ""
    ];

    //widsets http service parameters
    Value arg = [
      "url" => URL,
      "params" => params
    ];
    call(null, "httpService", "get", arg, ok, nok);
  }


  void ok(Object state, Value ret)
  {
    setBubble(null, "Got "+ret.size()+" bytes of html");
    //printing html to log
    printf(ret);
  }


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

} //class

widget.xml

<?xml version="1.0" encoding="utf-8"?>
 
<widget spec_version="2.0">
  <info>
    <name>example_http_service</name>
    <version>1.0</version>
    <author>example</author>
    <clientversion>1.0</clientversion>
    <shortdescription>Http Service Example</shortdescription>
    <longdescription>Http Service Example</longdescription>
    <tags>example httpservice</tags>
  </info>
   
  <parameters>
    <parameter name="widgetname">Http Service</parameter>
  </parameters>

  <services>
    <service type="http" id="httpService"/>
  </services>
  
  <resources>
    <code src="http_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>

Note. You can search for certain parts from html-pages by defining Archived:WidSets Filter expressions reference -filters to your http-service.

This page was last modified on 29 June 2012, at 08:44.
64 page views in the last 30 days.
×