0

Marketing API v7.0 (java lib: facebook-java-business-sdk.7.0.0)

I recently jumped from v5.0 to v7.0 and discovered that the following fields disappeared from the AdsInsights class:

@SerializedName("hourly_stats_aggregated_by_advertiser_time_zone")
private String mHourlyStatsAggregatedByAdvertiserTimeZone = null;
  
@SerializedName("hourly_stats_aggregated_by_audience_time_zone")
private String mHourlyStatsAggregatedByAudienceTimeZone = null;
 
@SerializedName("product_id") 
private String mProductId = null;

The last lib in which these fields were present was

 facebook-java-business-sdk.6.0.0

and first disappeared in version

facebook-java-business-sdk.6.0.4

I checked the change logs and found no details regarding these missing fields and it seems like an oversight. Any idea if/when these fields will return to the latest java libs?

Thanks.

Rich Johns
  • 81
  • 4
  • We are seeing an almost identical issue. Two fields that we use from that class, publisherPlatform and impressionDevice, have also been removed...as well as their matching accessors getPublisherPlatform and getImpressionDevices. I can't confirm that they first disappeared in 6.0.4 like you did, but I can confirm they are in 6.0 and not in 7.0 or 8.0. My requests for support from Facebook have told me to report this to the https://github.com/facebook/facebook-java-business-sdk, which we have. Not seeing much movement from this project, so not convinced it's supported very well at this point. – Greg Roberts Aug 31 '20 at 15:15

1 Answers1

0

In lieu of the fact that the reported bug hasn't been addressed in months, we were hoping to fix this by submitting code changes to the AdsInsights class in github project. Unfortunately, you're not allowed to change the autogenerated classes. So we came up with a different solution until the autogenerated classes are fixed. We created a separate maven project that ignores the autogenerated AdsInsights class file and allows us to include our own "slightly modified" version of AdsInsights. We copied and modified AdsInsights from v8.0.1 to include the missing data members and accessors that we required. The ones we require are different than the ones from the question asked, but the concept is exactly the same. If you're not sure what to change, look at the source code of v6.0.0 to see what it used to look like. Your pom should use a slightly modified artifactId so as not to conflict with any other versions you might have installed. I'm including the relevant parts of the pom we created. This solution worked perfectly for us with no issues with the functionality we added back in. `

<modelVersion>4.0.0</modelVersion>
<groupId>com.facebook.business.sdk</groupId>
<artifactId>facebook-java-business-sdk-yourcompanyname</artifactId>
<packaging>jar</packaging>
<version>8.0.1</version>
<name>facebook-java-business-sdk</name>
<description>A fork of Facebook's Business SDK containing patches/customizations needed for use cases</description>

<distributionManagement>
    <site>
        <id>documentserver</id>
        <url>${distributionManagement.baseUrl}/${project.artifactId}/${project.version}</url>
    </site>
</distributionManagement>

<properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <targetJdk>1.7</targetJdk>
</properties>

<dependencies>
    <dependency>
        <groupId>com.facebook.business.sdk</groupId>
        <artifactId>facebook-java-business-sdk</artifactId>
        <version>8.0.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-toolchains-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>toolchain</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <toolchains>
                    <jdk>
                        <version>${targetJdk}</version>
                    </jdk>
                </toolchains>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>${targetJdk}</source>
                <target>${targetJdk}</target>
                <verbose>true</verbose>
                <fork>true</fork>
                <compilerArgs>
                    <arg>-Xlint</arg>
                </compilerArgs>
            </configuration>
        </plugin>
        <!-- This will allow us to overwrite class files in the business SDK with our own versions defined in this project -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.facebook.business.sdk</groupId>
                                <artifactId>facebook-java-business-sdk</artifactId>
                                <version>8.0.1</version>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                <excludes>
                                    **/AdsInsights.class
                                </excludes>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

`

  • And of course, don't forget to change your dependency over to whatever you use for your artifactId. – Greg Roberts Sep 02 '20 at 18:00
  • Thanks Greg, appreciate your sharing of this option. However, on behalf of those that need the java lib updated, I'm asking someone from FB development reading this to please add the missing variables back to the codegen files, regen and build a new lib. There are at least 5 missing data members detailed above. Thank you. – Rich Johns Sep 07 '20 at 17:05
  • No problem Rich, that would definitely be the preferable option. However, in three weeks the current implementation will no longer work. The bug was reported 5 months ago and there's been no movement on it. Our company can't afford to lose our stat collection capabilities while we wait for a github fix. Cheers! – Greg Roberts Sep 08 '20 at 18:15
  • Greg, sorry to be dense, but what did you mean when you said this "However, in three weeks the current implementation will no longer work." BTW, I get 0 response on the github facebook / facebook-java-business-sdk issues page. This is where fb support said to put it so the crickets are baffling. – Rich Johns Sep 09 '20 at 19:23
  • Rich, if you refer the the following documentation: https://developers.facebook.com/docs/apps/upgrading and scroll down to the section on Marketing API Changelog. The "Available Until" date is Sept 28, 2020. We've also received alerts stating the same thing on our Facebook Developer account. And I do feel your pain with Facebook's response, we're pretty much used to that at this point. That's why we created the workaround. – Greg Roberts Sep 10 '20 at 17:18
  • Rich....gave you the wrong link. https://developers.facebook.com/docs/graph-api/changelog – Greg Roberts Sep 11 '20 at 14:44
  • Much obliged Greg. I thought you might be talking about v6.0 but given the fact that in the past the changelog sunset dates have been contradicted by FB back end servers, I wanted to make sure. Thanks again. – Rich Johns Sep 11 '20 at 18:25
  • Yes Rich, we've also noticed that Facebook doesn't always hold strictly to their sunset times. We have thousands of customers that rely on us to reliably report their FB AdsInsights so we just can't afford to play "Facebook Roulette". I still highly recommend you build a custom version of facebook-java-business-sdk using the solution I supplied and have it ready to go in case the github project continues to stall. It shouldn't take more than an hour to build. – Greg Roberts Sep 12 '20 at 05:18
  • More than 6 months later, this issue STILL exists in the autogenerated facebook-java-business-sdk autogenerated classes. – Greg Roberts Apr 01 '21 at 11:31
  • We have moved onto version 10.0.1 and Facebook still has not fixed these fields lost during the autogeneration of classes. For anyone using the workaround solution I posted above, make sure you change the version in the "unpack" section of the POM as well. – Greg Roberts May 07 '21 at 11:48