This library supplies a number of functions that interface to www.Facebook.com through the official Facebook Connect interface. The functions allow a user to login/logout, post messages/images, and retrieve status.
See the Facebook sample app shipped with the SDK for an example of how to use the interface.
IMPORTANT: As of build 2011.707, you must ensure your app works properly with single-sign on (SSO). Please read this tutorial for information on how to implement single sign-on in your Facebook-enabled apps.
This code has been picked up from PeachPellen's site which was based on Ansca's sample code.
It displays a login box and allows me to log in into my facebook account, but it posts nothing. Any ideas why?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | local function printTable( t, label, level ) if label then print( label ) end level = level or 1 if t then for k,v in pairs( t ) do local prefix = "" for i=1,level do prefix = prefix .. "\t" end print( prefix .. "[" .. tostring(k) .. "] = " .. tostring(v) ) if type( v ) == "table" then print( prefix .. "{" ) printTable( v, nil, level + 1 ) print( prefix .. "}" ) end end end end -- The above code should not be modified in anyway local function pressfb ( event ) if event.phase == "ended" then print ("pressed FB " ) local function postit( event ) print( event.name ) print( event.type ) if ( "session" == event.type ) then -- The above code is to use a button to publish, if you would prefer it automatically popped up remove the first two lines of the above and two "end"s at the bottom of this code. local attachment = { name = "Download Escape the Factory To Compete With Me", link = "http://itunes.apple.com/us/app/Escape-the-factory/id123456?mt=8", caption = "Think you can Escape the Factory? I dare you to try!", picture = "http://www.oz-apps.com/files/escape.png", actions = json.encode( { { name = "Get It Now!", link = "http://itunes.apple.com/us/app/Escape-the-factory/id123456?mt=8" } } ) } -- Change the wording of your post, your desired image and your links accordingly. facebook.request( "me/feed", "POST", attachment ) elseif ( "request" == event.type ) then local response = event.response if ( not event.isError ) then response = json.decode( event.response ) printTable( response, "friends", 3 ) end print( response ) elseif ( "dialog" == event.type ) then print( "dialog", event.response ) end end -- The above is taken directly from Corona and while I will admit I don't fully understand it, it works, so it's what I'm passing onto you guys. local appId = 123456789012345 if ( appId ) then facebook.login( "1234" .. "5678" .. "9012" .. "345", postit ) else local function onComplete( event ) system.openURL( "http://developers.facebook.com/setup" ) end -- Note that the app ID is IN QUOTES one time and NOT the other. Do not add or remove quotes, simply replace my ID with your own. native.showAlert( "Error", "To develop for Facebook Connect, you need to get an application id from Facebook's website.", { "Learn More" }, onComplete ) end end end fbButton:addEventListener("touch", pressfb) |
Try writing the Facebook appID as a string in quotation marks "12345678"
It worked for me....
I have implemented a Twitter library that functions very similarly to this Facebook library. I've been trying to imitate all of the small details about the Facebook library. There are two parts that I can't get:
1) The facebook login opens a web popup with an "x" button above it in the upper left corner. I know that native display objects always appear on top of everything else. How do you put a button above one?
2) When logging into facebook, a loading indicator pops up above the web popup. It says "loading" and has a spinning wheel. When I use native.setActivityIndicator(), there is just a spinning wheel. Can I make it say "loading" like the facebook one?
@mrmanuke - would you mind sharing your library?
It seems there's nothing working with twitter currently :/
Is it possible to do a FQL request with this API:
http://developers.facebook.com/docs/reference/fql/
I have tried , but can't get it to work.
I'm trying to publish an image to my FB app. I modified the sample and got it to publish to my own page, but only text using the dialog.
I assume it has to do with the params{} and adding attachment, which I was about to do, but when digging deeper into Facebook's documentation. I'm doing a lot of digging and looping, but not finding.
I don't know Lua, and I've managed to edit the samples enough (thanks to you guys) to get things working. I even added a listener to pause the sample otherwise the keyboard messes up (thanks to the dialog, not in the paid version I assume). Perhaps if I knew JSON I wouldn't ask this, but is there a quick way to put an image (that you just got from a screenshot) into a FB publish?
This is my last question before I'm capable of doing a project in this SDK. (so you know I'm not just endlessly taking your time for nothing!)