How can I identify the bug in my Java restfb call to post to my personal Facebook feed?

66 Views Asked by At

I am trying to complete a personal project where I run a Java app to get covid19 data from a state's website API, then posts the daily case count to my Facebook feed.

Part 1 was to figure out the covid19 API to get the data. That was easy and works.

Part 2 was to post that data to my Facebook page. That is way more complicated than I thought and I'm stuck.

I have created an app using Facebook developer tools. After getting some authentication errors I figured out how to get a working access token using a request from that app. I set the app to live. So no more "OAuth" error. I just copied and modified the simple code found on https://restfb.com/documentation/ in the Publishing a message section.

The problem is that it's not working and not giving me any error messages. Here is the code, using Java 11 and restfb 3.12.0:

FacebookClient facebookClient 
    = new DefaultFacebookClient(accessToken, Version.LATEST);

GraphResponse publishMessageResponse
    = facebookClient.publish("https://graph.facebook.com/xxxx/feed", 
     GraphResponse.class,Parameter.with("message", "RestFB test"));

System.out.println("Published message ID: " + 
    publishMessageResponse.getId());

"Published message ID: null" is what prints to the console. Nothing prints to my FB feed. There is no error returned to the IDE (Intellij IDEA). There is no log of anything happening when I look at the app in the developer site.

How can I track down the problem? I've been sort of lost in Facebook documentation (GraphAPI, Access Tokens, and App Review) and would appreciate a point in the right direction.

0

There are 0 best solutions below