- Basics
- Extended GUI
- Available features
- More
- Reference
- Examples
- Finishing
Twitter for Locify
This sample service allows user to save his updates on Twitter with GPS position. It also supports viewing public, user and friend timelines, favorite updates and account information using internal browser. It supports authentication to Twitter and uses settings for saving item count and default adding gps coordinates to statuses.
Welcome message
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Twitter for Locify</title> </head> <body class="serviceInfo"> <div> <p class="description">Updating your status on Twitter has never been simpler. This service allows you to send and receive Twitter status updates.</p> <img src="http://www.locify.com/images/socialicons/twitter.png" class="icon" alt="" /> <a href="http://services.locify.com/twitter/start" class="firstScreen">firstScreen</a> <a href="http://services.locify.com/twitter/settings" class="settings">settings</a> </div> </body> </html>
Settings screen
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Twitter settings</title> </head> <body class="form"> <form action="locify://serviceSettings" method="post"> <fieldset> <label>Displayed items (1-20): <input type="text" name="itemCount" value="$settings[itemCount]" /></label> <label>Add GPS coordinates: <select name="addgps" locify:selected="$settings[addgps]"> <option value="1">yes</option> <option value="0">no</option> </select></label> <input type="submit" value="Save" /> </fieldset> </form> </body> </html>
First screen
Action open is described below.
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Twitter for Locify</title> </head> <body class="list"> <ul> <li><a href="http://services.locify.com/twitter/postform" class="listItem">Update status</a></li> <li><a href="http://services.locify.com/twitter/timelines" class="listItem">Timelines</a></li> <li><a href="http://services.locify.com/twitter/open?view=favorites&count=$settings[itemCount]" class="listItem">Favorites</a></li> <li><a href="http://services.locify.com/twitter/account" class="listItem">Account</a></li> <li><a href="http://services.locify.com/twitter/login" class="listItem">Sign in</a></li> </ul> </body> </html>
Update status
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Twitter for Locify</title> </head> <body class="form"> <form action="http://services.locify.com/twitter/post" method="post"> <fieldset> <label>Status: <input type="text" name="status" value="" /></label> <label>Latitude: <input type="text" name="lat" value="$lat" /></label> <label>Longitude: <input type="text" name="lon" value="$lon" /></label> <label>Add GPS coordinates: <select name="addgps" locify:selected="$settings[addgps]"> <option value="1">yes</option> <option value="0">no</option> </select></label> <input type="submit" value="Update" /> </fieldset> </form> </body> </html>
Answer after update status
In case user is not logged a 401 HTTP status is returned and user login screen shows up. In case everything is OK, this alert shows up (alert is also used for some error messages):<?xml version="1.0" encoding="utf-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Info</title> </head> <body class="alert"> <div> <p class="text">Your Twitter status has been updated.</p> <a href="http://services.locify.com/twitter/start" class="next">next</a> <locify:timeout value="3000" /> </div> </body> </html>
Timelines
<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:locify="http://client.locify.com/locify_ns/1.0" xml:lang="en" lang="en"> <head> <title>Twitter Timelines</title> </head> <body class="list"> <ul> <li><a href="http://services.locify.com/twitter/open?view=publictl&count=$settings[itemCount]" class="listItem">Public</a></li> <li><a href="http://services.locify.com/twitter/open?view=friendstl&count=$settings[itemCount]" class="listItem">Friends</a></li> <li><a href="http://services.locify.com/twitter/open?view=usertl&count=$settings[itemCount]" class="listItem">User</a></li> <li><a href="http://services.locify.com/twitter/start" class="listItem">Back to Twitter menu</a></li> </ul> </body> </html>
Opening internal browser
Many pages of Twitter service are opened in internal browser. Note that neither cookies nor settings are currently shared between internal browser and standard message display so you need to create some workaround. (This is why count=$settings[itemCount] is present in URL for opening internal browser).
However, cookies are sent as GET parameters of first request internal browser makes (ie. URL with which it is opened).
