views:

41

answers:

1

Hello Friends

We are facing one problem with facebook. we integrated FB in our web application, when user login through fconnect in our web application then he registered with our system(1st time only) just providing his email id.For normal user few user i/p for registration in our system

Our web-application developed in java [GWT2.0].

Problem is when FACEBOOK or normaluser login through FB in our web-application.( 1 at a time)

when user refreshes page then FB pop window Occues with message

"Debug: Exception while loading FB.apiClient TypeError: $wnd.FB.Facebook is undefined"

or sometimes $wnd.FB.Facebook.apiClient is null occures

we get above error[pop-up] message 3 times.

we used following script in html page < script type="text/javascript" language="javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php">

In only 1 page of our web-application i.e UserHome page where we display users info . on that page only above error message occurs

We used following GWT Code [from Gwittit] In controller class[Singleton class ]

/** * Function get called when all the data on first page get loaded. * * */ public void notifyFinishedLoadinPage() { FacebookConnect.waitUntilStatusReady(new RenderAppWhenReadyCallback());

}

private MyLoginCallback loginCallback = new MyLoginCallback();

class MyLoginCallback implements LoginCallback {

    public void onLogin() {
        isFacebookSign = true;
        fbLoggedInUserId = ApiFactory.getInstance().getLoggedInUser();

        for (FacebookObserver Observer : facebookObservers) {
            Observer.notifyFacebookLogin(true);
        }
    }
}

public void publishStream(final FacebookObserver fbObserver) {
    FacebookConnect.init(FacebookConstants.FACEBOOK_API_KEY,

"xd_receiver.htm", loginCallback);

    FacebookConnect.requireSession(new

AsyncCallback() {

        public void onFailure(Throwable caught) {
            Window.alert("Require session failed: " + caught);
            GWT.log("Require session failed: " + caught, null);
        }

        public void onSuccess(Boolean isLoggedIn) {
            if (isLoggedIn) {
                for (FacebookObserver Observer :

facebookObservers) { Observer.notifyPublishStream(); } } } });

}

public void facebookConnection() {
    FacebookConnect.init(FacebookConstants.FACEBOOK_API_KEY,

"xd_receiver.htm", loginCallback); //SERVER FacebookConnect.requireSession(new AsyncCallback() {

        public void onFailure(Throwable caught) {
            GWT.log("Require session failed: " + caught, null);
        }

        public void onSuccess(Boolean isLoggedIn) {
            if (loginCallback != null && isLoggedIn) {
                loginCallback.onLogin();
            } else {
                //User not logged in
            }
        }
    });
}

/**
 * Fired when we know users status
 */
private class RenderAppWhenReadyCallback implements

AsyncCallback {

    public RenderAppWhenReadyCallback() {
        FacebookConnect.init(FacebookConstants.FACEBOOK_API_KEY,

"xd_receiver.htm", loginCallback); //SERVER }

    public void onFailure(Throwable caught) {
        Window.alert("Unable to login through Facebook: " + caught);
    }

    public void onSuccess(ConnectState result) {
        if (result == ConnectState.connected) {
            isFacebookSign = true;

            for (FacebookObserver Observer : facebookObservers) {
                Observer.notifyFacebookLogin(true);
            }

            //History.newItem(HistoryConstants.USERHOME_PAGE_HISTORY_TOKEN);
        } else {
            //rightSideFlexTable.clearCell(0, 0);
            //rightSideFlexTable.setWidget(0, 0,

facebookPanel); isFacebookSign = false;

        }
    }
};

Now we unable to found solution to this problem.

Can any one help Us to solve this problem ASAP

Hope-for the Best Co-operation

A: 

Hi friends

we found solution for above Question.

Facebook (login)loading requires few time.

In Our web page we fetch fb details like fb users loggedInId ,Image,etc. so at the time of page loading we get all values null because facebook not load properly so we get $wnd.FB.Facebook.apiClient is null or

Debug: Exception while loading FB.apiClient TypeError: $wnd.FB.Facebook is undefined"

To solve this problem we write one method which calls when user refreshes page or after facebook loading done properly.

public void notifyFacebookLogin(boolean isLogin) {

Long fbLoggedInUserId = ApiFactory.getInstance().getLoggedInUser();

if (fbLoggedInUserId != null) {

if (globalEndUserInfo == null) {
    globalEndUserInfo = new EndUserInfo();
    globalEndUserInfo.setFbLoggedInUserId(fbLoggedInUserId);
  }

}

// code wherever we deal with FB related object

}

Now no error message display when user refreshes page or if fb takes time to loading

In this way we solve our Problem. :)

Vaibhav Bhalke