More Twitter Tricks!

You may have seen the Twitter sample in Sample Folder 7: it shows how to use the Twitter control to add some basic Twitter functionality into your app.

You can add more functionality by controlling the Twitter app from your AppStudio program. To do this, you’ll need to have the Twitter app installed and be logged into it. Most Twitter users will not have to do anything extra.

Here’s what the sample app look like:

Screen Shot 2014-08-18 at 4.29.19 PM

The method we’ll use to control Twitter is its URL Scheme. This isn’t documented officially that we could find, but it seems to work well.

Here’s the code for the Timeline button: it opens the Twitter app in its Timeline view:

Function Button1_onclick()
  location = "twitter://timeline"
End Function

Substitute the name of the profile you want for “appstudiomobile”.

  location = "twitter://user?screen_name=appstudiomobile"

Displays the standard Notifications screen. This one seems to work on iOS, but not Android.

  location = "twitter://mentions"

Find User
Brings up a list of suggested users to tweet. Select one, then type the message you want.

  location = "twitter://messages"

Opens the Twitter app with the message you enter. Click on Tweet to send it.

  s = "twitter://post?message=" & encodeURIComponent(txtMessage.text)
  location = s

Here’s the complete undocumented list of Twitter URL codes:

twitter://mentions           'iOS
twitter://messages           'iOS or Android
twitter://post?message=hello%20world  'Android or iOS
twitter://status?id=12345    'status of a message. iOS only.
twitter://timeline           'iOS or Android
twitter://user?id=12345      'iOS or Android

We haven’t found a way to send a photo using this API. For that, you will probably need to use this more complex method: