Facebook "like" Code

Does anyone have some code to share on how to add a Facebook Like button?

I want the user to be able to tap a button to like my app’s facebook page.

thanks

This is not a trivial task, bordering on made impossible by Facebook.  You are probably best loading the page you want them to like in a native.newWebView().

Thanks Rob… I guess that is an option, although I am a bit curious why that would be so difficult. It’s just not a matter of sending a “like” request?

This is not a trivial task, bordering on made impossible by Facebook.  You are probably best loading the page you want them to like in a native.newWebView().

Thanks Rob… I guess that is an option, although I am a bit curious why that would be so difficult. It’s just not a matter of sending a “like” request?

@schizoid I don’t think fb makes ‘like’ available as an api request - only as a javascript based web button that you can put on pages

@schizoid I don’t think fb makes ‘like’ available as an api request - only as a javascript based web button that you can put on pages

@schizoid maybe this is something for you:

http://www.elevatefun.com/blog/likey-likey-integrating-facebook-like-buttons-corona-sdk/

haven’t really digged into this yet but it seems like the thing you’re looking for

That article is from 2011 and references 3rd party libraries.  I’m pretty sure Facebook has changed how the do Like buttons sense.  Please feel free to give it a go and if it works, we would welcome a guest blog post on how you got it to work.  Just on a quick pass, it seems it’s using some type of webView.   In the Facebook world, likes are used to like facebook pages and like news Articles.  If you want a button where your app users can like your facebook page, you could create a button that used system.openURL() to open a special facebook URL scheme to launch the FB app to that page.  You would need to check to see if it was successful or not, and if not, do a system.openURL() to the http: version of the page so it would open it in the browser.  See this Stack Overflow article:
 

http://stackoverflow.com/questions/12125780/custom-url-scheme-for-new-facebook-ios-app

I will try to figure it out in the next couple of weeks and report it to you guys. It seems that this feature is not possible over the API due to security reasons or whatever.

The documentation states:

The usage of the built-in Like action by an app, as with any Open Graph action, needs to be submitted and approved. For Facebook Pages or websites that do not integrate with Facebook Authentication, developers should continue to use the Like button social plugin.

I will try using the social plugin in a webview, maybe that’s the way to go. Launching the FB app is another possibility which I’d like to avoid as not everyone is using it.

Hey Walter,

Can you please tell me how I can check if the browser was successfully opened via system.openURL() ?

@schizoid maybe this is something for you:

http://www.elevatefun.com/blog/likey-likey-integrating-facebook-like-buttons-corona-sdk/

haven’t really digged into this yet but it seems like the thing you’re looking for

system.openURL should return true on success or false on failure to launch the app.

That article is from 2011 and references 3rd party libraries.  I’m pretty sure Facebook has changed how the do Like buttons sense.  Please feel free to give it a go and if it works, we would welcome a guest blog post on how you got it to work.  Just on a quick pass, it seems it’s using some type of webView.   In the Facebook world, likes are used to like facebook pages and like news Articles.  If you want a button where your app users can like your facebook page, you could create a button that used system.openURL() to open a special facebook URL scheme to launch the FB app to that page.  You would need to check to see if it was successful or not, and if not, do a system.openURL() to the http: version of the page so it would open it in the browser.  See this Stack Overflow article:
 

http://stackoverflow.com/questions/12125780/custom-url-scheme-for-new-facebook-ios-app

I will try to figure it out in the next couple of weeks and report it to you guys. It seems that this feature is not possible over the API due to security reasons or whatever.

The documentation states:

The usage of the built-in Like action by an app, as with any Open Graph action, needs to be submitted and approved. For Facebook Pages or websites that do not integrate with Facebook Authentication, developers should continue to use the Like button social plugin.

I will try using the social plugin in a webview, maybe that’s the way to go. Launching the FB app is another possibility which I’d like to avoid as not everyone is using it.

oh yes of course, thank you!

Hey Walter,

Can you please tell me how I can check if the browser was successfully opened via system.openURL() ?

system.openURL should return true on success or false on failure to launch the app.

oh yes of course, thank you!