Facebook/twitter buttons

Hi , I’ve put the following code together , but I want to add the system.openURL function , that redirect users to my facebook page , and one for my twitter , can anyone please continue the code , thanks you !  :slight_smile:
 

function new() local recipeGroup = display.newGroup(); local background = display.newImage("graphics/menu\_background2.png") background.y = 240 local facebook = display.newImage("graphics/facebook.png") facebook.x = display.contentWidth/2 facebook.y = 220 local twitter = display.newImage("graphics/twitter.png") twitter.x = display.contentWidth/2 twitter.y = 390 local topmenu = display.newImage("graphics/topMenuBar.png") topmenu.x = 180; topmenu.y = -24; local backButton = display.newImage("graphics/backButton.png") backButton.x = 35; backButton.y = -22; backButton.scene = "menu"; recipeGroup:insert(background); recipeGroup:insert(facebook); recipeGroup:insert(twitter); recipeGroup:insert(topmenu); recipeGroup:insert(backButton); backButton:addEventListener("touch", changeScene); return recipeGroup; end
local function showFacebookPage(event)      if event,phase == "ended" then            system.openURL("http://facebook.com/yourpage")      end      return true end   facebook:addEventListener("touch", showFacebookPage)

Now I would not use the names "facebook’ and “twitter” as variable names.  In the case of “facebook”, it’s a core API.  Even though you localized it, you wouldn’t be able to actually call the facebook API.  Twitter could be used in the future.   I would rename them facebookButton and twitterButton just to be safe.

This will open twitter and facebook in there native app.

system.openURL( “twitter://user?screen_name=yourusername” )

system.openURL( “fb://page/ID” )

You can find your ID by using this link : 

https://graph.facebook.com/yourusername

Kevin-

                            

For any kind of FB social button just go to developers.facebook.com and copy the code of button which you like and paste in code of your site.

Hi Justice.  Corona SDK is not a web based product.  You can’t just past those social buttons into your app.  You would have to build a webView in to post the buttons, but many of them require a webpage which our apps are not.

local function showFacebookPage(event)      if event,phase == "ended" then            system.openURL("http://facebook.com/yourpage")      end      return true end   facebook:addEventListener("touch", showFacebookPage)

Now I would not use the names "facebook’ and “twitter” as variable names.  In the case of “facebook”, it’s a core API.  Even though you localized it, you wouldn’t be able to actually call the facebook API.  Twitter could be used in the future.   I would rename them facebookButton and twitterButton just to be safe.

This will open twitter and facebook in there native app.

system.openURL( “twitter://user?screen_name=yourusername” )

system.openURL( “fb://page/ID” )

You can find your ID by using this link : 

https://graph.facebook.com/yourusername

Kevin-

                            

For any kind of FB social button just go to developers.facebook.com and copy the code of button which you like and paste in code of your site.

Hi Justice.  Corona SDK is not a web based product.  You can’t just past those social buttons into your app.  You would have to build a webView in to post the buttons, but many of them require a webpage which our apps are not.

The fp://page/ID url didn’t work for me on the iPhone. The Facebook app opens but won’t show my app’s page. According to http://wiki.akosma.com/IPhone_URL_Schemes#Facebook it does not seem to be a valid scheme (the page part).

Instead I use this code to open my Facebook app page in the Facebook app, if it is installed or else in the browser.

if(not system.openURL("fb://profile/348502405277307")) then   system.openURL("https://www.facebook.com/WordnRoll") end

And for Twitter :

if(not system.openURL("twitter://user?screen\_name=WordnRoll" )) then system.openURL("https://twitter.com/WordnRoll") end

Actually if you go to the bottom of the Facebook block on that wiki page, they say it should work.  I tried it and it does not seem to work the way it should.  I tried /pages/XXXXXXX, /page/XXXXXXX and /XXXXXXX and none seemed to work.    I doubt this is anything on our end since we are just opening the URL and the native facebook app doesn’t seem to be recognizing it.

Hi Rob,

True I didn’t see that. With fb://profile/xxxx it seems to work. 

The Facebook API cannot allways be trusted in my experience as a webdeveloper  :wink:

Hi Jack01/Rob,

humm this is strange, it work in android.

-Kevin p.s. i’m doing a kickstarter, http://kck.st/18b6VbJ  any support is welcome!

The fp://page/ID url didn’t work for me on the iPhone. The Facebook app opens but won’t show my app’s page. According to http://wiki.akosma.com/IPhone_URL_Schemes#Facebook it does not seem to be a valid scheme (the page part).

Instead I use this code to open my Facebook app page in the Facebook app, if it is installed or else in the browser.

if(not system.openURL("fb://profile/348502405277307")) then   system.openURL("https://www.facebook.com/WordnRoll") end

And for Twitter :

if(not system.openURL("twitter://user?screen\_name=WordnRoll" )) then system.openURL("https://twitter.com/WordnRoll") end

Actually if you go to the bottom of the Facebook block on that wiki page, they say it should work.  I tried it and it does not seem to work the way it should.  I tried /pages/XXXXXXX, /page/XXXXXXX and /XXXXXXX and none seemed to work.    I doubt this is anything on our end since we are just opening the URL and the native facebook app doesn’t seem to be recognizing it.

Hi Rob,

True I didn’t see that. With fb://profile/xxxx it seems to work. 

The Facebook API cannot allways be trusted in my experience as a webdeveloper  :wink:

Hi Jack01/Rob,

humm this is strange, it work in android.

-Kevin p.s. i’m doing a kickstarter, http://kck.st/18b6VbJ  any support is welcome!