Page 1 of 1

launching twitter App.

Posted: Tue Mar 29, 2016 3:59 pm
by Jellobus
Hi All,

Here is my pseudocode for launching Twitter app. if the Twitter app is installed on the android device, the handler launches Twitter app to post message. but if there is no Twitter app installed on the device, the handler launches the web page instead. My code below is not working.. have any idea to make it work? It will be very appreciated if anyone advice me.. :D

Code: Select all

on postOnTwitter
    local tURL, pBody
    put url "twitter://post?message=" into tURL ##url of twitter app
    if tURL is empty then ## if there is no Twitter app installed.
       put "This is my message!" into pBody
       launch url "http://www.twitter.com/intent/tweet?text=" & urlEncode(pBody)
    else ## if there is Twitter app installed.
       launch url "twitter://post?message=This is my message!"
    end if
    put empty into tURL
end postOnTwitter
Thanks a lot in advance!

Louis

Re: launching twitter App.

Posted: Tue Mar 29, 2016 9:09 pm
by FourthWorld
Does Twitter still support write operations through their URL scheme? I had thought those were deprecated, but would love to be mistaken. Where can I learn more about their current URL scheme? Their dev site search is, shall we say, less than specific.

Re: launching twitter App.

Posted: Wed Mar 30, 2016 1:29 am
by Jellobus
Hi Forthworld,

Yes, URL scheme still works. If I command launch url "twitter://post?message=message here.", it directly launches Twitter app.

The question I am asking here is not how to launch Twitter app but how to launch twitter in webbrowswer if user doesn't have twitter app in their device.

Just I lke to know the method that figures out whether app is lauched or not. Any idea?


Louis

Re: launching twitter App.

Posted: Wed Mar 30, 2016 1:56 am
by FourthWorld
Ah, thanks.

I haven't tried this myself, but I would imagine if you try a url scheme that isn't valid because the app isn't installed, "the result" would contain an error message. On the desktop an invalid url returns "The default action does not support this protocol."

What happens if you try something like this?:

Code: Select all

 launch url "twitter://post?message=message here."
if the result is not empty then launch url "https://twitter.com/username/etc"

Re: launching twitter App.

Posted: Wed Mar 30, 2016 5:55 am
by Jellobus
Hi ForthWorld,

How do you get the result? Whatever I tried, it returns only empty in both with and without twitter app launched.

Code: Select all

local tUrl
launch url "twitter://post?message=message here."
put url "twitter://post?message=message here." into tUrl
answer tUrl