[weatherbug_getLocation]

Description

Link: [weatherbug_getLocation]
Author: Shelane Enos
Category: Utility
Version: 8.x
License: Public Domain
Posted: Apr. 01, 2007
Updated: Apr. 01, 2007
More by this author...
Returns location information (city, state, country) via the WeatherBug API.
Requires a valid WeatherBug API key. This tag also requires the [xml_tree]
type.

Parameters

-key string, required A valid WeatherBug API key.
-zip string, required The zip code to use in the search.

Sample Usage

var: 'wbLocale' = weatherbug_getLocation(-key=$key, -zip=$zip);
var: 'wbCurrentCity' = $wbLocale->find('location')->find('cityname');
var: 'wbCurrentState' = $wbLocale->find('location')->find('statename');

$wbCurrentCity ', ' $wbCurrentState;
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
define_tag(
	'getLocation',
	-namespace='weatherbug_',
	-required='key',
	-required='zip',
	-priority='replace',
	-description='Returns location information for the given zip code.'
);

	local('url' = 'http://' + #key + '.api.wxbug.net/getLocationsXML.aspx');
	local('getparams') = array(
		'ACode' = #key,
		'SearchString' = #zip
	);
	
	local('response') = include_url(
		#url,
		-getparams=#getparams
	);
	
	local('xmldata') = xml_tree(#response);

	local('out' = map);
	iterate(#xmldata->locations->children, local('i'));
		if(#i->name && #i->name != 'text');
				local('map' = map);
				#map->insert('value' = #i->contents);
				
				if: #i->attributes;
					iterate: #i->attributes, (local: 'attribute');
						#map->insert(#attribute->first = decode_xml(#attribute->second));
					/iterate;
				/if;
				#out->insert(#i->name = #map);
		/if;
	/iterate;
		
	return(@#out);		
/define_tag;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net