0

I'm working on a mobile project and decided to try out the LWUIT framework for development. So far it has been quite interesting although I wish the documentation was a bit better.

I run into a problem trying to post content to facebook using the recently released Facebook API. I'm able to authenticate without issues. However, when I try to post comments to the user's wall, I get a http 404 error.

Has anyone else had this sort of challenge. Below is an excerpt from my code;

   protected boolean onShareScreenPost() {
    // If the resource file changes the names of components this call will break notifying you that you should fix the code
    //boolean val = super.onShareScreenPost();        

    Form shareForm = Display.getInstance().getCurrent();
    final TextField shareField = findShareField(shareForm);
    String postText = shareField.getText();
    try {
        makeFacebookAuthenticationRequest();
        FaceBookAccess.getInstance().postOnWall(me.getId(), postText);
    } catch (IOException ex) {
        ex.printStackTrace();
        //Include a dialog saying unable to post or connect to the internet or whatever

    }


    return true;
}

private void makeFacebookAuthenticationRequest() throws IOException {
        FaceBookAccess.getInstance().authenticate("125527160846284", "http://a.b.c/", new String[]{ "publish_stream"});            
        me = new User();
        FaceBookAccess.getInstance().getUser("me", me, new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                System.out.println("returned user");
            }
        });
}
frayab
  • 2,512
  • 20
  • 25
bcombes
  • 31
  • 4
  • you have this problem on emulator?or mobile? – frayab Jan 14 '12 at 14:29
  • This problem occurs on the emulator (Java ME 3.0.5 SDK), the Facebook Demo App works fine, but the examples don't include posting to the user's wall. – bcombes Jan 14 '12 at 18:24

1 Answers1

1

Seeing this question 24 hours later makes me feel a bit silly.

The answer was quite simple and staring me in the face all along. I needed to wait for the Facebook API to return a User object before making additional calls to the API. Failure to do this resulted in a null reference for my user object and this was being used in the wall post request causing the facebook api to return a http 404.

Hope this helps someone...

bcombes
  • 31
  • 4