Advertisement
Hendrix000007

main file for facebook update

Mar 7th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local facebook = require "facebook"
  2.  
  3. -- You must use your own app id for this sample to work
  4. local fbAppID = "fb342224545897895" --fake
  5.  
  6. local function onLoginSuccess()
  7. -- Upload 'iheartcorona.jpg' to current user's account
  8. local attachment = {
  9. message = "My score on Manic RowBuster.",
  10. source = { baseDir=system.ResourceDirectory, filename="myFame.jpg", type="image" }
  11. }
  12. facebook.request( "me/photos", "POST", attachment )
  13. end
  14.  
  15. -- facebook listener
  16. local function fbListener( event )
  17. if event.isError then
  18. native.showAlert( "ERROR", event.response, { "OK" } )
  19. else
  20.     if event.type == "session" and event.phase == "login" then
  21.         onLoginSuccess()
  22.     elseif event.type == "request" then
  23.         native.showAlert( "Success", "The photo has been uploaded.", { "OK" } )
  24.     end
  25. end
  26. end
  27.  
  28. -- photo uploading requires the "publish_stream" permission
  29. facebook.login( fbAppID, fbListener, { "publish_stream" } )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement