PDA

View Full Version : Using GraphAPI with Sencha Touch



gabrielstuff
29 Jul 2010, 12:04 PM
Hi Small World :)
I am trying to use GRAPHAPI from facebook to generate nestedlist item.

I use this very simple code :


<script>
window.fbAsyncInit = function() {
FB.init({appId: '142465915771077',
status: true,
cookie: true,
xfbml: true});

FB.api('/me/feed/', function(response) {
alert_message(response);
});

};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());

var alert_message = function(response){
for (var i=0, l=response.data.length; i<l; i++) {
var post = response.data[i];
if (post.message) {
alert('Message: ' + post.message);
}
}
};

</script>

My question was as fellow. I am not use to Ext, and I was wondering how to add and includes the call to the facebook JS SDK. I actually was wondering if I should use the source and include them.
Then I was trying to understand when to call my different function.

I know it seams very blurry... but I am in this mood actually :)

Thank to every one that will help :)

evant
29 Jul 2010, 6:23 PM
I'd suggest following whatever the FB library suggests in their sample code.

gabrielstuff
30 Jul 2010, 7:36 AM
Hi evant !
Nice to have my first talk with you.
I've noticed that you are an active user. Actually I met ExtJS with one of your post as I was reading and searching about panel, tabs and framework. I discover ExtJS with the forum ^^

Actually, I am already using sample code from facebook.
The one above is one of them.

All this code are working fine in a "classic" environment. Meaning, no ext-js lib inclusion and no separate script.

My challenge here (a small one) is to be able to run it in the ExtJS (Sencha) environment.
I've read carrefully the source of twitter app and twittmap app (also did the tut) but the way facebook js library is called cause me some difficulties.

They speak about :


The most efficient way to load the SDK in your site is to load it asynchronously so it does not block loading other elements of your page:

That is what I am doing... but when I use the code that worked in a classic environnement it does not with Sencha.

Hints ? help ?

Thank you !

gabrielstuff
6 Aug 2010, 5:34 AM
Hi !
Actually a simple call to

Ext.util.JSONP.request({
url: 'http://graph.facebook.com/106986762688577/feed/',
callbackKey: 'callback',
callback: function(data) {
data = data.data;
facebook.update(data);
}
});
was sufficient to what I need to do. Nevertheless I am still interesting to see how facebook connect, and Sencha Touch framework cohabitated.