Skip to content

Instantly share code, notes, and snippets.

@dtinth
Created May 8, 2013 04:58
Show Gist options
  • Save dtinth/5538291 to your computer and use it in GitHub Desktop.
Save dtinth/5538291 to your computer and use it in GitHub Desktop.
Testing Titanium
var facebook = require('facebook')
facebook.appid = '175681919257376'
facebook.permissions = [ 'read_requests', 'publish_stream' ]
var onPosted = function(e) {
if (e.success) {
alert("Posted to facebook!")
} else {
alert("Failed posting to facebook!")
}
}
var onLogin = function(e) {
if (e.success) alert("Login success!")
}
var onLogout = function() {
alert("On logout!!")
}
facebook.addEventListener('login', onLogin)
facebook.addEventListener('logout', onLogout)
var window = Ti.UI.createWindow({
backgroundColor: '#353433'
})
var loginButton = facebook.createLoginButton({
top: 50,
style: facebook.BUTTON_STYLE_WIDE
})
var textField = Ti.UI.createTextField({
top: 100, left: 20, right: 20
})
var sendButton = Ti.UI.createButton({
top: 150,
title: 'Post'
})
sendButton.addEventListener('click', function() {
facebook.requestWithGraphPath('me/feed', { message: textField.getValue() }, "POST", onPosted)
})
window.add(loginButton)
window.add(textField)
window.add(sendButton)
window.open()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment