0

I need to be able to update (using any API in JAVA) the info of my Facebook Pages, such as address, opening time hours, email, tel etc., but, I have not been successful. I have tried restfb library and Facebook Graph API. The code in restfb I used is:

List<FacebookPage> fbPagesList=new ArrayList<>();

fbPagesList=readPagesInfo(); // suppose this function returns a list of needed info
    for(FacebookPage fbPage: fbPagesList) {
        updateFacebookPageInfo(fbPage);
    }

private static void updateFacebookPageInfo (FacebookPage fb) {

    String fullAddress  = fb.address2 != null && !fb.address2.isEmpty()
            ? fb.address1 + ", " + fb.address2
                    : fb.address1;
    

Hours hours=new Hours();
// timeSlotsExtrat  is a function that returns a  List<String> of opening hours
        hours.addHour(DayOfWeek.MON.toString() , timeSlotsExtrat (fb.monday).toString());
        hours.addHour(DayOfWeek.TUE.toString() , timeSlotsExtrat (fb.tuesday).toString());
        hours.addHour(DayOfWeek.WED.toString(), timeSlotsExtrat(fb.wednesday).toString());
        hours.addHour(DayOfWeek.THU.toString(), timeSlotsExtrat(fb.thurdsay).toString());
        hours.addHour(DayOfWeek.FRI.toString() , timeSlotsExtrat (fb.friday).toString());
        hours.addHour(DayOfWeek.SAT.toString() , timeSlotsExtrat (fb.saturday).toString());
        hours.addHour(DayOfWeek.SUN.toString() , timeSlotsExtrat (fb.sunday).toString());


        Location location = new Location();  
        location.setCityId(fb.city_id); 
        location.setStreet(fullAddress);
        location.setZip(fb.zipCode);
        location.setLongitude(Double.parseDouble(fb.longitudine));
        location.setLatitude(Double.parseDouble(fb.latitudine));

        List<String> emails =new ArrayList<>();
        if(fb.email !=null && !fb.email.isEmpty()) {
            emails.add(fb.email);
        }
        try {
 
            DefaultFacebookClient fbClient = new DefaultFacebookClient(fb.page_access_token, Version.LATEST);
            GraphResponse response = fbClient.publish(fb.page_id, GraphResponse.class,
                    Parameter.with("location", location),
                    Parameter.with("phone", fb.tel),
                    Parameter.with("hours", hours),
                    Parameter.with("website", fb.website),
                    Parameter.with("emails", emails));
            System.out.println("Response: " + response.isSuccess());

        } catch (FacebookOAuthException e) {
            // OAuth-related exceptions (e.g., permissions or token issues)
            System.err.println("1_ OAuth error: " + e.getErrorMessage());
        } catch (FacebookGraphException e) {
            // Errors from the Facebook Graph API itself
            System.err.println("2_ Graph API error: " + e.getErrorMessage());
        } catch (FacebookResponseStatusException e) {
            // Errors related to the execution of the API call
            System.err.println("3_ Response error: " + e.getErrorMessage());
        } catch (Exception e) {
            // Other errors
            System.err.println("4_ Update failed: " + e.getMessage());
        }

    }
    

Interestingly I receive no errors and response.isSuccess() prints true, however I see no changes on my Facebook page except for the website!!!!

enter image description here

the second method I have tried is explained here.

_ I have even tried to report a bug for Facebook but as you see in the photo below it is not possible anymore Report a Bug

2
  • 1
    I suggest you go step by step through the changes. For example: change only the street and check, if it is changed on Facebook. Then change the zip code, check on Facebook and so on. The interesting part is, which of the location info is changed, and which not or which triggers the not working change. As soon as you have found the culprit you can fix it or open a bug on Facebook.
    – Norbert
    Commented Mar 14 at 11:22
  • @Norbert, I am unable even report a bug, Facebook has cancelled this service, I share the screenshot inside the question text Commented Mar 19 at 9:00

0