Lasso Soft Inc. > Home

[weatherbug_getalerts]

Linkweatherbug_getalerts
AuthorJason Huck
CategoryUtility
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted08 May 2006
Updated08 May 2006
More by this author...

Description

Returns alert conditions for given zip code via the WeatherBug API. Requires a valid WeatherBug API key.

Sample Usage

weatherbug_getalerts(
	-key=$key,
	-zip=$zip
)->first;

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.

define_tag(
	'getalerts',
	-namespace='weatherbug_',
	-required='key',
	-required='zip',
	-priority='replace',
	-description='Returns alert conditions for given zip code.'
);
	local('url' = 'http://' + #key + '.api.wxbug.net/getalerts.aspx');
	local('getparams') = array(
		'acode' = #key,
		'zipcode' = #zip
	);
	
	local('response') = include_url(
		#url,
		-getparams=#getparams
	);
	
	#response->replace(' xmlns:aws="http://www.aws.com/aws"','')&replace('aws:','');
	
	local('xmldata') = xml(#response);			
	local('out' = array);
	
	if(string(#xmldata->extract('//alerts/text()')->first) == 'No Alerts at this time.');
		#out->insert('No Alerts at this time.');
	else;
		local('alerttypes') = #xmldata->extract('//alert/type/text()');
		local('alerttitles') = #xmldata->extract('//alert/title/text()');
		
		iterate(#alerttypes, local('i'));
			local('map' = map);
			
			#map->insert(#i = #alerttitles->get(loop_count));
			
			#out->insert(#map);
		/iterate;
	/if;
	
	return(@#out);
/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft