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.

1
  • 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 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. Commented Aug 31, 2020 at 15:15

1 Answer 1

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>

`

Sign up to request clarification or add additional context in comments.

10 Comments

And of course, don't forget to change your dependency over to whatever you use for your artifactId.
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.
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, 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, if you refer the the following documentation: 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.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.