Easy Twitter integration

Hi, I have this installed and working - thank you! - but if I have no Internet connection the popup does not display?

Is there a way to determine if user has connection before attempting to display the page?

Thanks [import]uid: 125592 topic_id: 9695 reply_id: 102056[/import]

This is code that I have used in the past

  
local networkAvailable = false  
function MyNetworkReachabilityListener( event )  
 if event.isReachable then  
 networkAvailable = true  
 print("online")  
 -- do something here if online  
 else  
 networkAvailable = false  
 print("offline")  
 -- do something here if offline  
 end  
end  
  
function checkOnline()  
 if network.canDetectNetworkStatusChanges then  
 network.setStatusListener( "www.twiiter.com", MyNetworkReachabilityListener )  
 else  
 print("network reachability not supported on this platform")  
 networkAvailable = false  
 end  
end  

Hope that helps!

Stefan [import]uid: 2646 topic_id: 9695 reply_id: 102058[/import]

well noted. great. [import]uid: 63983 topic_id: 9695 reply_id: 104741[/import]

Is there any kind of remote method to twit ?

https://mobile.twitter.com/intent/tweet&text=Blablabla

But for a mobile device ?

PS: would be nice to have Twitter API just like Facebook API in Corona.

Tom [import]uid: 111283 topic_id: 9695 reply_id: 106393[/import]

Has anyone had any problems using this methos with Facebook? What happens for me is the webpop launches, but nothing ever loads. The Twitter works, no problem.

Here is my whole code in it’s pretty messy entirety.

[code]

local fbButton = display.newImage (imgPath … “Fb_Blue.png”)
fbButton.x = display.contentWidth *.8
fbButton.y = display.contentHeight * .6

local twButton = display.newImage (imgPath …“Tw_Blue.png”)
twButton.x = display.contentWidth *.7
twButton.y = display.contentHeight *.6

local closeButton
local webPopBG

function closeWindow(event)
native.cancelWebPopup()
if closeButton ~= nil and closeButton.removeSelf then
closeButton:removeSelf( )
end
if webPopBG ~= nil and webPopBG.removeSelf then
webPopBG:removeSelf()
end
end

local function callTW(event)
if event.phase == “ended” then
closeButton = display.newImage(imgPath …“closeBack.png”)
closeButton.x = display.contentWidth *.75
closeButton.y = 30
closeButton:addEventListener(“touch”,closeWindow)

webPopBG = display.newRect(0,0,display.contentWidth, display.contentHeight)
webPopBG:setFillColor(0,0,0,50)

local message = “I got " …scoreInfo… " on Circus Big Pop Lite! Can you beat that? http://itunes.apple.com/us/app/circus-big-pop-lite/id521759035?ls=1&mt=8
local theString = string.gsub(message, “( )”, “%%20”)
native.showWebPopup( 20,40,display.contentWidth *.8 ,display.contentHeight *.8, “https://twitter.com/intent/tweet?text=” …theString)
end

end

local function callFB (event)
if event.phase == “ended” then
closeButton = display.newImage(imgPath …“closeBack.png”)
closeButton.x = display.contentWidth *.75
closeButton.y = 30
closeButton:addEventListener(“touch”,closeWindow)

webPopBG = display.newRect(0,0,display.contentWidth, display.contentHeight)
webPopBG:setFillColor(0,0,0,50)

local fbMessage = “I got " …scoreInfo… " on Circus Big Pop Lite!”

native.showWebPopup( 20,40,display.contentWidth *.8 ,display.contentHeight *.8, “https://facebook.com/dialog/feed?app_id=343967615657719&link=http://itunes.apple.com/us/app/circus-big-pop-lite/id521759035?ls=1&mt=8&picture=http://c2mpg.com/media/9878/1.jpg&redirect_uri=http://www.facebook.com/CircusBigPop?sk=wall&name=” …fbMessage… “&description=Can you beat my score?”)
end
end

fbButton:addEventListener(“touch”, callFB)
twButton:addEventListener(“touch”, callTW)

[/code] [import]uid: 97023 topic_id: 9695 reply_id: 107112[/import]

Stefan,

Thanks very much for the Facebook code. It works for me, but when the popup comes up, Facebook is requiring the user to login even though the app has already logged the user in. Very inconvenient to the user!

If I login and send the post, then kill the app and restart it, the popup does not require another login.

Does this happen to you too? (I’m running Daily Build 2012.819)

Best,

Mike [import]uid: 49460 topic_id: 9695 reply_id: 107929[/import]

@fremontmj ,

FYI : This is the “normal” behavior anyway as Ansca has stated here:

[lua]-- Project: Facebook Connect sample app

– Date: December 24, 2010

– Version: 1.5

– File name: main.lua

– Author: Ansca Mobile

—>> After a successful login event, send the FB command
—>> Note: If the app is already logged in, we will still get a “login” phase

Hope that clears it up for you.
Rodrigo. [import]uid: 89165 topic_id: 9695 reply_id: 107956[/import]

@ Rodrigo,

Thanks. Two questions:

* I can only find a copy of that template that says it is version 1.3, can you post a link to the version in your post?

* My understanding of that comment is that the Facebook event listener will get a “login” phase each time you make a Facebook call. Not that the user will have to *manually* log in again. Here is what happens (in more detail than I posted before):

  1. my app logs you in. You see a quick Facebook webpage that disappears on its own, without user input (because the device was already logged in to Facebook).

  2. my app opens a webPopUp to post to a user, as described by Stefan:

native.showWebPopup(0, 0, 320, 400, “http://www.facebook.com/dialog/feed?to=100001520411382&display=touch&redirect_uri=http://www.playfulthinking.org&app_id=237309533041737&link=http://www.playfulthinking.org/zorch&name=zorch&caption=testCaption2&message=testMessage2”, {urlRequest=popupListener})

  1. then, even though the user is already logged in, instead of getting a “Post” popup, I first get a login screen. It would be OK if that screen disappeared on its own (like in step 1). But it doesn’t. The popup behaves as if the user was not logged in at all, and forces the user to log in *again*.

This is not how Facebook Single Sign On is supposed to work!

Am I doing something wrong, or is this a bug?

Thanks again,

Mike

[import]uid: 49460 topic_id: 9695 reply_id: 107975[/import]

Oops, sorry for the bad formatting. Here’s that code line again:

[code]

native.showWebPopup(0, 0, 320, 400, “http://www.facebook.com/dialog/feed?to=100001520411382&display=touch&redirect_uri=http://www.playfulthinking.org&app_id=237309533041737&link=http://www.playfulthinking.org/zorch&name=zorch&caption=testCaption2&message=testMessage2”, {urlRequest=popupListener})
[/code] [import]uid: 49460 topic_id: 9695 reply_id: 107977[/import]

Hi @Mike,

Yes, now I understood you better.

By the way, I do not think you`re doing something wrong. And as you described above, yes, for me too that is an “abnormal” behavior (by my understanding). Would be that a bug? :\

So, about the file 1.5, you can get that at the Facebook sample code provided by Ansca into latest stable build 2012.704 and if it is not there, it is into daily build 706 for sure and it does support the SSO as well.
Look there please,
Rodrigo. [import]uid: 89165 topic_id: 9695 reply_id: 107983[/import]

Hi, i have twitter working great and am now trying to get Facebook working in the same way.

I have it set up so that a user can successfully post, but is it possible to have the redirect_uri take the user to view their own wall after they submit their post?

I could only get this working by having the redirect_uri going to Facebook.com

Im just a bit worried that the user does not get confirmation that they have posted without seeing it…

Thanks, [import]uid: 125592 topic_id: 9695 reply_id: 112498[/import]

@neil6,

What about including into your code some kind of pop-up alert (Native iOS Alert popup) telling the user that his post was done complete or even if it`s error?

Would be an option?
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 9695 reply_id: 112564[/import]

the facebook ios version of my app which posts scores has stopped working. the android version works for both, the twitter version of the ios one works, only the face book version has stopped.

it use to just post after logging in. now the face book app opens and closes. (i do have the app on my phone). the app is in test mode, being loaded directly to my phone and not via itunes.

and to repeat. it was posting just fine. no changes to code. just stopped working a few weeks ago.

i am stumped. anyone thoughts?
carl [import]uid: 147966 topic_id: 9695 reply_id: 115063[/import]

i have a question

  1. twitter feed run in a browser outside app = login is saved properly, user is not asked to log everytime

  2. twitter feed run in webView = login is not saved properly, user is asked to login everytime

native.showWebPopup(0, 0, 320, 480, “http://twitter.com/intent/tweet?text=My%20tweet%20goes%20here”)

Is this is a bug or ios setting ?

Tom [import]uid: 111283 topic_id: 9695 reply_id: 125246[/import]

i have a question

  1. twitter feed run in a browser outside app = login is saved properly, user is not asked to log everytime

  2. twitter feed run in webView = login is not saved properly, user is asked to login everytime

native.showWebPopup(0, 0, 320, 480, “http://twitter.com/intent/tweet?text=My%20tweet%20goes%20here”)

Is this is a bug or ios setting ?

Tom [import]uid: 111283 topic_id: 9695 reply_id: 125246[/import]

Hey Everyone,

I have posted a tutorial on using Twitter in Corona SDK. It build off of the Twitter Example included in the Corona SDK source code.

Some of the issues I address are:

  1. Saving access keys for authenticated users. Users will not be prompted again unless they de-authorize the app.
  2. Use the Twitter Rest API to follow a twitter account
  3. Use the Twitter Rest API to post an image to twitter.

http://velluminteractive.com/upload-images-to-twitter-from-corona-sdk/

Let me know what you think!
Brian Reinhart [import]uid: 158289 topic_id: 9695 reply_id: 125869[/import]

Hey Everyone,

I have posted a tutorial on using Twitter in Corona SDK. It build off of the Twitter Example included in the Corona SDK source code.

Some of the issues I address are:

  1. Saving access keys for authenticated users. Users will not be prompted again unless they de-authorize the app.
  2. Use the Twitter Rest API to follow a twitter account
  3. Use the Twitter Rest API to post an image to twitter.

http://velluminteractive.com/upload-images-to-twitter-from-corona-sdk/

Let me know what you think!
Brian Reinhart [import]uid: 158289 topic_id: 9695 reply_id: 125869[/import]

@Peach
@spjnowak

How would I go about using this simple functionality to POST an image I already have saved using screen capture ? Or is it not that simple for images.

Thanks [import]uid: 53149 topic_id: 9695 reply_id: 133688[/import]

Brian’s link right about your comment talks about how to upload pics to Twitter :slight_smile: [import]uid: 52491 topic_id: 9695 reply_id: 133717[/import]

@Peach :slight_smile: About that… I saw that and was hoping for a simpler solution. Me laaaaaaaazeeeeee today :slight_smile: [import]uid: 53149 topic_id: 9695 reply_id: 133731[/import]