10/28/2013

Tips & Tricks for web service query via Tasker

Sometimes we want to retrieve useful information from internet via Tasker, e.g. weather forecast, phone number area etc. We can use “HTTP POST/GET” action ATM. In general, the specific information which we want, embedded in the webpage we query from. It will need much more seconds and data traffic, and we have to use some complicated and annoyed steps, e.g. “Variable Split” or “Variable Search Replace” etc., to extract the specific information from it. Now I have some tips and tricks for this situation. Here I suppose you have known how to use “HTTP POST/GET” action via Tasker. Here we go.

-------------------------------------------------------------

Almost all webpages we retrieved, consist a lot of useless parts. So why not use other professional web services with API documented? These professional web services often provide specific API and refined output, e.g. output in XML, JSON format. Make good use of Google Search to find these professional web services first, guys.

For example, how to get the attribution and operator information from specific phone number in China? I can do it with with the free web service here, and it provide detailed API. With “HTTP GET(URL: http://www.sososjw.com/json?Tel=13888888888)”, we can get refined output in internal variable “%HTTPD” about the phone number 13888888888. Here is the content of “%HTTPD” for it:

{"Tel":"1388888","Province":"云南","City":"昆明","AreaCode":"0871","PostCode":"650000","Corp":"中国移动","Card":"GSM"}

It’s in JSON format, and it’s very simple and useful. Here I suggest that you’d better use “Javascript(let)” action to parse the value of element. The script below will flash ‘昆明’ , the value of “City” element for former ouput.

var info = JSON.parse(global("HTTPD"));
flash(info.City);

Also we can get weather forecast from professional web service.

e.g.
for city ‘大连(Da lian)’ in China http://m.weather.com.cn/data/101070201.html

A example for San Franciso http://api.wunderground.com/api/Your_Key/forecast/q/CA/San_Francisco.json

Perhaps you need learn some tutorial lessons about JSON and javascript from online W3School. Maybe you can use app “JOSN Viewer” to format raw JSON data and view the elements in tree structure.



"JSON Viewer" online: http://www.jsoneditoronline.org/
"JSON Viewer" for Win: http://jsonviewer.codeplex.com/  http://tomeko.net/software/JSONedit/index.php
"JSON Viewer" for Android: https://play.google.com/store/apps/details?id=eu.borzaindustries.jsondroid&hl=zh_CN

---------------------------------------------------

Sometimes you couldn’t find any web service with API.
There is a little trick that you can try its WAP service for help. Usually, some webpage use a refined WAP page for lower end mobile browser. You’ll feel lucky if the specific web service with a WAP page provided and you find it really available.

e.g. A weather forecast WAP page about Shanghai in China: http://www.weather.com.cn/wap/weather/101020100.shtml

For those who are not so lucky, there is another trick that you can use online RSS service to extract specific information from webpage and burned it into RSS feed URL. Here I strongly recommend you’d better use ‘feed43’ or ‘Yahoo Pipes’ to do the work. The ‘Yahoo Pipes’ is much more powerful than the former one. I’ve use the feed43 service to extract and burn a RSS feed about MIUI daily motto in my another article.

----------------------------------------------

Sometimes you’ll find the output of web service is useful, but not so concise, especially a little webpage with lots of useless HTML tags. I suggest that you can use “Variable -> Variable Convert –‘Html to text’” function to convert ‘%HTTPD’ into Text, then you can process the text more concisely.

OK. That’s all from my experience. Although I haven’t share you a plenty of online web service, you’ll find things become much more easier if you know the tricks. Principle or thoughts goes first, I always believe in this.

Reference:
1. something wrong with JSON.parse()?
2. Tasker来电归属地设置
3. 开源免费天气预报接口API以及全国所有地区代码!!(国家气象局提供)
4. Sickbeard today's shows to pebble (Android+Tasker)


10/07/2013

Homemade Tasker Creations for Home Use

Here is some of my homemade tasker creations using scenes for home use.

Screenshots:

Wifi Password Viewer:

Shell Command Debugger:

Lyrics Show for PowerAMP:

Calculator:

Tasks Search & Run:

Special Symbols Pad:

Screen Filter: