Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Android - Facebook Module don't work!!

$
0
0

[ERROR] :  FacebookModule: (main) [38143,71824] LoginDialogListener onFacebookError: The connection to the server was unsuccessful.
[ERROR] :  FacebookModule: com.facebook.android.FacebookError: The connection to the server was unsuccessful.
[ERROR] :  FacebookModule:  at com.facebook.android.Facebook.onSessionCallback(Facebook.java:433)
[ERROR] :  FacebookModule:  at com.facebook.android.Facebook.access$000(Facebook.java:97)
[ERROR] :  FacebookModule:  at com.facebook.android.Facebook$2.call(Facebook.java:379)
[ERROR] :  FacebookModule:  at com.facebook.Session$3$1.run(Session.java:1239)
[ERROR] :  FacebookModule:  at android.os.Handler.handleCallback(Handler.java:587)
[ERROR] :  FacebookModule:  at android.os.Handler.dispatchMessage(Handler.java:92)
[ERROR] :  FacebookModule:  at android.os.Looper.loop(Looper.java:123)
[ERROR] :  FacebookModule:  at android.app.ActivityThread.main(ActivityThread.java:3687)
[ERROR] :  FacebookModule:  at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] :  FacebookModule:  at java.lang.reflect.Method.invoke(Method.java:507)
[ERROR] :  FacebookModule:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
[ERROR] :  FacebookModule:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
[ERROR] :  FacebookModule:  at dalvik.system.NativeStart.main(Native Method)
[ERROR] :  FacebookModule: (main) [4,71828] onAuthFail: The connection to the server was unsuccessful.
this is the error that I get when I try to log in on Android... on iOS it works fine but on Android it don't work.

my code:

////////////////////////////////////////////////////////
var fb = require( 'facebook' );
fb.appid = 755377651155999;
fb.permissions = [ 'user_events', 'user_friends', 'friends_events', 'rsvp_event' ];
fb.forceDialogAuth = true;
////////////////////////////////////////////////////////
 
// current Window e Nav
var win = Ti.UI.currentWindow;
 
////////////////////////////////////////////////////////
// Background
win.backgroundImage = '/imagens/background.png';
////////////////////////////////////////////////////////
// LOGO
var logo = Ti.UI.createImageView({
    image: '/imagens/img_deuvicky.png',
    width: 196,
    height: 195,
    top: 100
});
win.add( logo );
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// LOADING
var rectPreto = Ti.UI.createView({
    backgroundColor: 'black',
    opacity: 0.8,
    zIndex: 20
});
////////////////////////////////////////////////////
var viewLoading = Ti.UI.createView({
    zIndex: 25
});
////////////////////////////////////////////////////
var loading = Ti.UI.createActivityIndicator({
    style: Ti.UI.ActivityIndicatorStyle.BIG
});
viewLoading.add( loading );
////////////////////////////////////////////////////////
// FACEBOOK BUTTON
var botao = Ti.UI.createView({
    bottom : '20%',
    backgroundImage: '/imagens/fbBtn.png',
    backgroundSelectedImage: '/imagens/fbBtnOver.png',
    width: 197,
    height: 48
});
win.add( botao );
 
botao.addEventListener( 'touchstart', function(e){
 
    botao.backgroundImage = '/imagens/fbBtnOver.png';
    label.image = '/imagens/fbLabelOver.png';
 
});
 
 
botao.addEventListener( 'touchend', function(e) {
 
    botao.backgroundImage = '/imagens/fbBtn.png';
    label.image = '/imagens/fbLabel.png';
 
 
    win.add( rectPreto );
    win.add( viewLoading );
    loading.show();
 
    fb.authorize(); 
});
//
//
//
var label = Ti.UI.createImageView({
    image: '/imagens/fbLabel.png',
    width: 148,
    height: 26
});
botao.add( label );
//
//
//
fb.addEventListener('login', function(e){
    if (e.success) {
 
 
        var faceID = e.uid;
        var result = JSON.parse( e.data );
        var sexo = result.gender;
        var nome = result.first_name;
        var nomeComp = result.name;
 
        Ti.API.info( 'SEXO: ' + sexo );
        Ti.API.info( 'NOME: ' + nome );
 
        var xhrFunc = function(){
 
            var xhr = Ti.Network.createHTTPClient({
 
                onerror:function(e){
 
                    Ti.API.info( 'Error: ' + e.error );
                    xhrFunc();
                },
 
                onload:function(e){
 
                    Ti.API.info( 'Resposta: ' + this.responseText );
 
                    Ti.App.Properties.setString( 'saiuListaNegra' , true );
                }
            });
 
            xhr.open( 'GET', 'http://www.grupomatiz.net/vicky/retirar_off.php?id_fb=' + faceID );
            xhr.send();
        };
        xhrFunc();
 
        Ti.App.Properties.setList( 'listaInfFace', result );
 
        if( sexo == 'female' ){
 
            Ti.App.Properties.setString( 'procuraHomem', true );
            Ti.App.Properties.setString( 'procuraMulher', false );
 
 
 
        }else if( sexo == 'male' ){
 
            Ti.App.Properties.setString( 'procuraHomem', false );
            Ti.App.Properties.setString( 'procuraMulher', true );
        }
 
        Ti.App.Properties.setString( 'IDFace', faceID );
        Ti.App.Properties.setString( 'sexoFace', sexo );
        Ti.App.Properties.setString( 'meuNomeFace', nome );
 
 
        var nextWin = Ti.UI.createWindow({
            backgroundColor: '#eeeeee',
            url: '/jsAndroid/rMenu.js',
            exitOnClose: true,
            navBarHidden: true,
            borderRadius: 5
        });
 
        nextWin.open();
 
        nextWin.addEventListener( 'android:back', function(){
 
            //nextWin.close();
 
        });
 
        //Ti.API.info( '==============================' );
        //Ti.API.info( '==============================' );
        //Ti.API.info( '==============================' );
 
 
    } else if (e.error) {
 
        var alerta = Ti.UI.createAlertDialog({
            message: L( 'ErroXhr2' ),
            buttonNames: [ L('Ok', 'Ok') ],
            title: L( 'ErroXhr1' )
        });
        alerta.show();
 
        win.remove( rectPreto );
        win.remove( viewLoading );
 
    } else if (e.cancelled) {
 
        var alerta = Ti.UI.createAlertDialog({
            message: L( 'ErroXhr2' ),
            buttonNames: [ L('Ok', 'Ok') ],
            title: L( 'ErroXhr1' )
        });
        alerta.show();
 
        win.remove( rectPreto );
        win.remove( viewLoading );
    }
});
 
////////////////////////////////////////////////////////

Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>