Created
May 8, 2013 04:58
-
-
Save dtinth/5538291 to your computer and use it in GitHub Desktop.
Testing Titanium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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