Alternate way to use Facebook and Twitter in app?

I can’t figure it out. I’m getting this error in the console window. What code do I have to require in order to get this to work? Is it JSON?

bad argument #1 to 'gsub' (string expected, got table)

Regards,
Jordan Schuetz
Ninja Pig Studios [import]uid: 29181 topic_id: 19775 reply_id: 83886[/import]

this looks good…however, I have a couple of dumb questions:

what do you pass here function (theMessage, theNetwork)?
why do you declare your variables (theNetwork) inside the function if your expecting something call the same?

last dumb question, how is this better than using the code inside the samples folder to post to twitter and facebook? at least that seems to give you a callback to give the user some message of whether it got posted or not.
if someone could please post a final snippet of how y’all got it together, that’ll be awesome.

Thanks!

-RD [import]uid: 7856 topic_id: 19775 reply_id: 83891[/import]

Uh oh. I waited until the last minute to mess with the Facebook thing, and now it isn’t working. When I change the app id from Facebook’s sample code into my Facebook app ID, I get the error, as you can see here.

I assume that the problem is in my Facebook app settings, but I don’t see what? What exactly do you have filled out in the app settings on Facebook? [import]uid: 38000 topic_id: 19775 reply_id: 85953[/import]

I also just noticed that I can change all the parameters using the example app ID and it will work, except for one. When I change the redirect_uri from Facebook’s default (www.example.com/response), I get the same error message that I do when I try it with my own ID. Does this mean that the redirect_uri has to match some specific setting with Facebook? Has anyone else been able to change the redirect_uri with Facebook’s sample app?
Thanks for your help in advance!
Peter [import]uid: 38000 topic_id: 19775 reply_id: 85973[/import]

FWIW, here’s the alternate way looks like when I tried it. I followed @finefin’s instruction, and it worked nicely (using daily build 706.) I decided to go with integrating Facebook API after all, but I’m posting this just in case it helps. See below.

BTW, in terms of which is better, you’d want to implement both and decide which works better for you. Single Sign On feature that’s been implemented in daily build 707 would be (in my opinion) so much better, but I’m still using daily build 706 at the moment…

Naomi

[lua] local function testNetworkConnection()
local netConn = require(‘socket’).connect(‘www.apple.com’, 80)
if netConn == nil then
return false
end
netConn:close()
return true
end

local function popUpWeb()
if ( testNetworkConnection() ) then
local redirectUri = “http://www.mygamesite.com”;
local fbLink = “http://www.mygamesite.com”;
local fbPic = “http://www.mygamesite.com/mylogo.png”;
local app_id = “123456789”; – this is the app id for the game from FB dev page
local fbName = “My%20Game”;
local message = string.gsub( “It’s super fun. Try it out and beat my score!”, “( )”, “%%20” )
native.showWebPopup( 10,10, screenW-20, screenH-60, “http://www.facebook.com/dialog/feed?display=touch&app_id="..app_id.."&redirect_uri="..redirectUri.."&link="..fbLink.."&picture="..fbPic.."&name="..fbName.."&description=”…message )
end
end
– When a user presses a button, the popUpWeb function launches.
– Some space on the bottom of the screen is set aside to display “close” button that would close the popup
– This one is set up for portrait view.[/lua]
[import]uid: 67217 topic_id: 19775 reply_id: 85984[/import]

error with redirect URL

Make sure the our beloved iPhone can load up the URL! whilst developing I used my old company website as a placeholder but it didn’t work as it contained flash !

Hope this helps [import]uid: 3093 topic_id: 19775 reply_id: 86025[/import]

@Naomi - Thanks for the code! However, I see the same problem as before. If I use the code as you’ve given (Changing your app ID to the example app id, 123050457758183) it gives me an error, but if I switch the redirect Uri to the one from the docs (http://www.example.com/response/), or for that matter, any pages within that one domain (http://www.example.com/) it works fine. this leads me to believe that the redirectUri must be a somewhere in the Facebook app settings. I just can’t seem to find it there.
Does this code (with the correct ID) work for you?

@Dominic.wood - Thanks for the advice! however, it’s not a problem of the page not loading, Facebook just shows a page saying there is an error. [import]uid: 38000 topic_id: 19775 reply_id: 86180[/import]

@Blue Spruce Games, I entered the URL in Facebook dev page for the game app. Meaning, both URLs used for redirectUri and fbLink are on the Facebook dev page for the game. Also, the logo.png does exist and it appears properly on website. I think it’s important to use the URL that you control for this purpose when you release your game… Also, for the App ID (Facebook app ID), maybe you should try using your own?

Naomi [import]uid: 67217 topic_id: 19775 reply_id: 86189[/import]

That’s exactly what I was planning to do. I just kept getting errors when I used my own app ID. Where exactly is the field on Facebook’s settings for the redirectUri and the FBLink? I didn’t see it on the settings when I first set up the app.
Thanks for all your help!
Peter [import]uid: 38000 topic_id: 19775 reply_id: 86195[/import]

Hi Peter @Blue Spruce Games, there’s no mention of redirectUri in FB dev page. What I meant was to use the real URL that you control for the code I posted above (post #24). On FB dev page, I enter the real existing site URL and Mobile web URL (which are identical URL). FYI, I haven’t selected Native iOS App on Facebook dev page. All I’ve selected so far are Website and Mobile Web.

I hope you’ll get yours working very soon.

Naomi [import]uid: 67217 topic_id: 19775 reply_id: 86196[/import]

I see! I had been trying to redirect to a page I had made on my website for the purpose, instead of redirecting to my website. Now it works fine. Thanks for your help! [import]uid: 38000 topic_id: 19775 reply_id: 86202[/import]

Hey, Peter, glad to hear it works for you now!

Naomi [import]uid: 67217 topic_id: 19775 reply_id: 86205[/import]

This works fine for me without any changes (apart from FB ID and the URLs).

I did change the function name from -

fin.sendSocial = function (theMessage, theNetwork)

To -

local function sendSocial (theMessage, theNetwork)

As I couldn’t understand how to call the first one and kept getting errors (am new to Lua).

Thanks to -

canupa.com for posting the code.
dominic.wood for explaining what each item means.
Naomi for explaining what I needed to fill in on the FB page (my App isn’t in the App Store).

Dave [import]uid: 117617 topic_id: 19775 reply_id: 87841[/import]

I tried implementing Canupa’s code but I noticed something odd: the webpopup on iOS opens mobile Safari on the first button click rather than a webpopup window. on subsequent clicks, it works as expected. this is using build 758.

any ideas why this might be happening? i’ve noticed it for other popups too. [import]uid: 1560 topic_id: 19775 reply_id: 90888[/import]

For some reason when I go to developers.facebook.com/apps it just redirects me to login to facebook and takes me to my starting page. Does anyone know if there is a new way to register an app with facebook so I can get my app id?

Thanks!
Bento [import]uid: 118346 topic_id: 19775 reply_id: 92665[/import]

Found my own answer:

Stack overflow [import]uid: 118346 topic_id: 19775 reply_id: 92758[/import]

Everything seems to work fine until after I try to log in. Then I only get the error “An error occurred with “Name of my app”. Please try again later.”

Obvious it know’s what app I’m trying to use since it uses the name of the app in the error message which can only be found on the Facebook developer page. And it’s kind of hard to get any debugging done from this point, anyone know any potential things that could have gone wrong?

Thanks! [import]uid: 103492 topic_id: 19775 reply_id: 93140[/import]

I suggestion for people who having problem with facebook connect, add “&show_error=true” to your URL and you will get a more proper error message. [import]uid: 103492 topic_id: 19775 reply_id: 93158[/import]

Can anyone help me , I want to post photo on facebook but NOT with a URL ,
just by passing the image data.

I referred a blog http://blog.anscamobile.com/2011/12/uploading-photos-to-facebook-in-corona/

but still am getting a blank white screen after I log in .

Please help asap

Thank u [import]uid: 95790 topic_id: 19775 reply_id: 94761[/import]

@seth.vedangi, are you able to confirm that your log in was successfully executed?

If you are using Facebook API (instead of the alternate way described under this thread), use a bunch of print statements and see what you are getting for event.type and event.phase – it might really help clue you in.

I had an issue when I changed from daily build 706 to 767. It turned out that one of the great library that I use with my project called ice changed the way it requires json. It used to require it as a global variable, but it now require it in locally. I was not aware of it, but after I updated ice along with the update to 767, Facebook post routine broke. Doing the series of print statements clued me in to the source of the issue. Once I understood the problem, all it took for me to fix it was to require json in my main.lua – and everything works perfectly fine again.

Naomi [import]uid: 67217 topic_id: 19775 reply_id: 94824[/import]