{ "id": "60659", "key": "TIMOB-27", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11213", "name": "Release 0.7.0", "archived": true, "released": true, "releaseDate": "2009-10-05" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:50:10.000+0000", "created": "2011-04-15T02:22:41.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "facebook", "ios", "iphone" ], "versions": [], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:50:10.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}
The purpose of this API is to enable developers to use the\nFacebook Connect Objective-C API via Javascript
\nThe first step is to create a Facebook Session
\n\n\nvar session = Titanium.Facebook.createSession({\n apiKey:'my_api_key',\n appSecret:'my_app_secret',\n proxyURL:'my proxy url'\n});\n\nvar isLoggedIn = session.resume();
\n
\nReturns true if user is already logged in, otherwise it returns\nfalse
\nWe need to add support for two Facebook iPhone buttons:
\n\nTitanium.Facebook.CONNECT_BUTTON\n\nTitanium.Facebook.LOGOUT_BUTTON
\n
\nThese should be supported via the systemButton property of the\nTitanium.UI.createButton API.
\nNote: the login button when clicked automatically shows the\nLogin Dialog
\nThis API creates and displays the Facebook Login Dialog
\n\n\nvar dialog = Titanium.Facebook.createLoginDialog({\n session:mySessionObject,\n});\n\ndialog.show();
\n
\n\nsession.addEventListener('login',function(session)\n{\n // returns the updated session object after successful login\n});
\n
\nThis API creates and displays the Facebook Extended Permission\nDialog
\n\nvar dialog = Titanium.Facebook.createPermissionsDialog({\n permission:'permission_string'\n success:function()\n {\n // permission granted - do something cool\n },\n cancel: function()\n {\n // permission not granted - too bad\n }\n});\n\ndialog.show();
\n
\nThis API enables you to call any of the support Facebook Connect\nAPIs
\n\n\nvar requestData = {name:'value',name2:'value2'};\n\nvar request = Titanium.Facebook.executeAPI({\n name:'api_name',\n data:requestData,\n function(result)\n {\n // result should be JSON object return from API call\n }\n\n});
\n
\nThis API allows you to publish a story to a user's feed.
\n\n\nvar templateDataObj = {key:'value'};\n\nvar dialog = Titanium.Facebook.createFeedDialog({\n templateBundleId: 12345,\n templateData: templateDataObj,\n function(result)\n {\n // was post successful\n }\n});\n\ndialog.show();
\n
A few questions:
\nI don't like the session.resume() method - seems weird. Is this\ntheir name? Can we just use session.isLoggedIn()? Or is this the\napi that causes session to start? Maybe if it is, we could have a\nsession.connect() to cause it to connect and then\nsession.isLoggedIn() would return true/false depending on if you've\nalready done this (or not).
\nis there an API to see if we already have a permission? i.e. I\ndon't want to show dialog if permission has already been granted...\nhow would you do that?
\nwe need a logout capability -- session.logout() ?
\nFacebook connect (and further OAuth) could be a really killer\nfeature for Desktop as well..
I ended up implementing the API a little differently.
\nCreate a Facebook login/logout button and bind it to a specific\nID. You can add and remove listeners from this button once\ncreated.
\n\nvar button = Titanium.Facebook.createLoginButton({\n 'id':'b',\n 'style':'normal',\n 'apikey':Titanium.App.Properties.getString(\"facebook.apikey\"),\n 'secret':Titanium.App.Properties.getString(\"facebook.secret\")\n});\nbutton.addEventListener('login',function()\n{\n console.info(\"LOGIN\");\n});\nbutton.addEventListener('logout',function()\n{\n console.info(\"LOGOUT\");\n});
\n
\nThe style property can either be normal (default if not\nspecified) or wide.
\nYou can execute FQL query.
\n\nTitanium.Facebook.query(\"select uid,name from user where uid == \"+Titanium.Facebook.getUserId(),function(r)\n{\n console.info(\"QUERY RESULT RETURNED success = \"+r.success+\", error = \"+r.error+\", data=\"+r.data);\n});
\n
\nYou can cause explicit login
\n\nTitanium.Facebook.login(function(result)\n{\n console.info(\"login success=\"+result.success);\n});
\n
\nYou can cause explicit logout
\n\nTitanium.Facebook.logout(function(result)\n{\n console.info(\"logout success=\"+result.success);\n});
\n
\nYou can determine the login status.
\n\nTitanium.Facebook.isLoggedIn();
\n
\nYou can determine the user id of the logged in user or null if\nnot logged in
\n\nTitanium.Facebook.getUserId();
\n
\nYou can request extend permissions
\n\nTitanium.Facebook.requestPermission(\"publish_feed\",function(result)\n{\n console.debug(\"permission success=\"+result.success);\n});
\n
\nYou can publish to users feed
\n\nTitanium.Facebook.publishFeed(123456789,{'img':'http://foo/bar.png'},'nolan is cool',function(result)\n{\n console.debug(\"publish success success=\"+result.success);\n});
\n
(from [6ec20bf4ca21c075ece508f4def5f2c4daa7c86d])\n[#27\nstate:open] added initial Facebook Connect module for iphone\n\nhttp://github.com/appcelerator/titanium_mobile/commit/6ec20bf4ca21c...
you can execute a facebook method. the 2nd parameter is optional\nand is any data (as javascript json object) to pass to the\nmethod.
\n\nTitanium.Facebook.execute(\"facebook.Users.getStatus\",null,function(evt)\n{\n console.info(\"evt = \"+evt+\", success=\"+evt.success+\",cancel=\"+evt.cancel+\",error=\"+evt.error+\",json=\"+Ti._JSON(evt.data));\n});
\n
added in 0.7.0