launching twitter App.

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

launching twitter App.

Post by Jellobus » Tue Mar 29, 2016 3:59 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: launching twitter App.

Post by FourthWorld » Tue Mar 29, 2016 9:09 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Re: launching twitter App.

Post by Jellobus » Wed Mar 30, 2016 1:29 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: launching twitter App.

Post by FourthWorld » Wed Mar 30, 2016 1:56 am

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"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Re: launching twitter App.

Post by Jellobus » Wed Mar 30, 2016 5:55 am

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

Post Reply