0

could someone please explain how i can do this? Im trying to get a FB access token and append it to a URL string in a store config. As such...

Ext.define('clubs.store.FacebookEvent', {
extend: 'Ext.data.Store',
requires: [
    'clubs.model.FacebookEvent'
],

config: {
    autoLoad: true,
    model: 'clubs.model.FacebookEvent',
    //storeId: 'FacebookEventStore',
    proxy: {
        type: 'jsonp',
        url: 'https://graph.facebook.com/474381199275383/?fields=description,name&access_token=' + getAccessCode(),

        reader: {
            type: 'json'
            //rootProperty: 'data'
        }
    }
}

});

function getAccessCode(){
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        var uid = response.authResponse.userID;
        var accessToken = response.authResponse.accessToken;
        console.log(accessToken);
    }
});
return accessToken;

}

However i seem to always get this error in my JS console...

uncaught Error: The following classes are not declared even if their files have been loaded: 'club.store.FacebookEvent'. Please check the source code of their corresponding files for possible typos:

Am i going about this the wrong way? Any help would be much appreciated!

4

2 回答 2

1

Ideally you should put this in controller or any singleton utility class and then access it like this:

this.getApplication().getController('ControllerName').getAccessCode()

OR

UtilsClass.getAccessCode()

But if you want to keep it here you have to define the function like this:

config : {
    //..blah blah
},
getAccessCode : function(){
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
    var uid = response.authResponse.userID;
    var accessToken = response.authResponse.accessToken;
    console.log(accessToken);
    }
  });
  return accessToken;
}
于 2013-01-26T07:52:42.873 回答
0

You only need to change the class definition from

Ext.define('clubs.store.FacebookEvent',

to

Ext.define('club.store.FacebookEvent',

In fact your app name is club and not clubs.

于 2013-01-23T17:46:57.107 回答