Tasker HTTP 'get' example

In this example we want to use Tasker's HTTP 'GET' feature to retrieve data from the Web which Tasker assigns to a %HTTPD variable.

This is useful because we can then split the %HTTPD variable data down to just the specific data we need which we can use to display something to the user. In this example, we will split the %HTTPD variable down to obtain the current 'Sunset' time at a given zipcode location.

Create a Task.

Creating a Task

1. Launch Tasker by clicking its application icon. icon_tasker.png
2. Click 'Task'.
3. On the 'Task Edit' window, click 'New' and enter a name for this task. In this example we'll call the Task 'Sunset'.

Create a list of ‘Actions’ to perform on the ‘Task Edit’ screen for this Task.

Creating a list of 'Actions' to perform.

First we need to set some static data for the location we want to receive the Sunset time for.

1. Click ‘+’ and click ‘Variable’ and then click ‘Variable Set’.
2. In the 'Name' box, enter '%ZIPCODE'.
3. In the 'To' box, enter the actual zipcode where you live.
4. Click 'Done'

Second we need to go to the web and get some data.

5. Click ‘+’ and click ‘Net’ and then click ‘HTTP Get’.
6. In the 'Server:Port' box, enter 'xml.weather.yahoo.com/forecastrss?p=%ZIPCODE'.
7. Swipe down and long-press click on the 'Mime Type' and select 'text/xml'.
8. Click 'Done'

Third, we need to 'split' the data (break it down) to get the specific data we want which in this example will be the 'Sunset' time.

9. Click ‘+’ and click ‘Variable’ and then click ‘Variable Split’.
10. In the 'Name' box, enter '%HTTPD'.
11. In the 'Splitter' box, enter 'sunset="'. (Note: That's a double quotation mark preceding the the closing single quotation mark).
12. Click 'Done'

13. Click ‘+’ and click ‘Variable’ and then click ‘Variable Split’.
14. In the 'Name' box, enter '%HTTPD2'.
15. In the 'Splitter' box, enter ' pm'. (Note: There is a 'space' before the 'p')
16. Click 'Done'

Optional: If you want to display the time in 24hr clock format, then you will need to add twelve hours so that the time is displayed in 24hr time format.

17. Click ‘+’ and click ‘Variable’ and then click ‘Variable Split’.
18. In the 'Name' box, enter '%HTTPD21'.
19. In the 'Splitter' box, enter ':'.
20. Click 'Done'
21. Click ‘+’ and click ‘Variable’ and then click ‘Variable Add’.
22. In the 'Name' box, enter '%HTTPD211'.
23. Change the 'Value Slider' to '12'.
24. Click 'Done'
25. Click ‘+’ and click ‘Variable’ and then click ‘Variable Join'.
26. In the 'Name' box, enter '%HTTPD21'.
27. In the 'Joiner' box, enter ':'.
28. Click 'Done'

Finally, we need to do something with this so we'll just display the Sunset time to the user on the Notification Bar.

29. Click ‘+’ and click ‘Alert’ and then click ‘Notify’.
30. In the 'Title' box, enter 'Sunset is %HTTPD21 pm'.
31. In the 'Text' box, enter 'Today's Sunset time is at %HTTPD21 pm'.
32. Click 'Done'
Note: We should leave off the ' pm' if we display the time in 24hr clock format of course.

Now RUN this task and it will go to the Yahoo RSS page and retrieve the 'Sunset' time and display it on the Notification Bar.

Page Contribution

This page was contributed by DaWeav.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License