1
votes

I've been trying to use the native sharebutton integrated into the Codename one project, except that when I click "Post", a "400 : Bad Request" error appears. No exception is thrown, and I have no stacktrace in my console.

Code :

    ShareButton sb = new ShareButton();
    sb.addActionListener((evt) -> {
        System.out.println("clicked");
    });
    hi.add(sb);

    sb.setImageToShare("file://home/230r3EdWRk4kP6WDiMBM", "image/jpg");
    sb.setTextToShare("Test facebook");
    hi.show();

Another inssue is that the text to share is invisible.

Screenshot

2

2 Answers

1
votes

400 just means bad request. This could be for many reasons. Make sure that the file path you provided exists etc..

AND

I seem to recall that Facebook no longer lets you share an Image and text at the same time. You can do one or the other. If you want to share something that has an image and text, you need to create a dynamic webpage that uses their Open Graph Markup, and share a link to that. Then it will be formatted nicely in the news feed.

It's been a while since I've had to do this, so I'm going by memory here... Things could have changed.

0
votes

Thanks,

I fixed my problem by following the Facebook Demo at this link :https://github.com/codenameone/codenameone-demos/tree/master/FacebookDemo

Turns out that there are issues with the builtin share button, so you need to use multipart requests.