Flash required to explore WidSets
The newest version of the Flash Player is required to explore WidSets. Please download and install the free Flash Player from the icon below.
After installation, refresh this page »
HTTP Post and response
HTTP Post and response
Hi guys and girls,
I hope I'm not going over old ground here, but here I go...
I'm planning to devlop at widget that that includes a text box that users enter a keyword or phrase into. The keyword or phrase is posted to an URL and the response is wrote to the shell.
Is it possible to do this, and are there any examples on this. At the moment I'm trying to piece together different bits from different examples, input box from UI Test, HTTP service etc...
Any help would be gratefully received.
Re: HTTP Post and response
You need to utilize the call() method in a way like this:
your_params = ["title" => "your title"];
call(null, "httpService" , "post", ["url" => your_url, "params" => your_params], success, failure);
void success(Object state, Value ret)
{
..
}
void failure(Object state, String error)
{
..
}
Additionally you need to create a "httpService" handler in the widget.xml (http://dev.widsets.com/wiki/Widget_Configuration_2.1) file.
<services>
<service type="http" id="httpService">
<filter id="xpathfilter"/>
</service>
</services>
An in this example i receive an XML file from the request and therefore I apply the "xpathfilter"-filter (http://dev.widsets.com/wiki/Advanced_filters). You can leave it out if you wish.
<filters>
<filter id="xpathfilter">
<xpath>/statuses</xpath>
<list>
<foreach>
<xpath>status/*</xpath>
<item>
<name>
<xpath>name()</xpath>
</name>
<value>
<xpath>text()</xpath>
</value>
</item>
</foreach>
</list>
</filter>
</filters>
This filter applies to a twitter-feed. And in the success-callback you can use ret[2][1] to get the text of the first post.. This is only possible if you use the xpath-filter.
Hope it brings light.
/// Xotonium
