The Salesforce Marketing Cloud Java SDK enables developers to easily access the Salesforce Marketing Cloud (formerly ExactTarget) via the Java platform. Among other things, the SDK:
-
automatically acquires and refreshes Marketing Cloud access tokens
-
enables developers to access both Marketing Cloud SOAP and REST APIs in the same session with or without proxies.
-
exposes simplified versions of the most commonly used Marketing Cloud objects and methods as Java native objects
-
provides passthroughs so developers can access the full REST and SOAP APIs directly when they need to go beyond the simplified interfaces
-
adds "sugar" methods for the most commonly used Marketing Cloud features that make it easy to use those features (e.g., the SDK provides a SQL-like interface to data extensions)
For more information about the Java SDK and how to use it, please see the Javadocs at http://salesforce-marketingcloud.github.io/FuelSDK-Java/.
The easiest way to install the Java SDK is via Maven—simply add the following dependency to your project's pom.xml
:
<dependency>
<groupId>com.snippetexample</groupId>
<artifactId>flamessdk</artifactId>
<version>1.0.0</version>
</dependency>
Maven will automatically resolve, download, and install all dependencies for you.
Once you have the SDK installed, you'll need to obtain a client ID and client secret from App Center and place them in fuelsdk.properties
using src/main/resources/fuelsdk.properties.template
as a starting template. Theses values authenticate you to the Saleforce Marketing Cloud API. Please see https://code.exacttarget.com/getting-started/setting-your-development-environment for more information about how to use App Center to get a client ID and client secret.
public ETClient getETClient(){
if(etClient == null){
ETConfiguration configuration = new ETConfiguration();
configuration.set("clientId",exactTargetCredentials.getClientId());
configuration.set("clientSecret",exactTargetCredentials.getClientSecret());
try {
ETProxy etProxy = new ETProxy(ProxyServerType.HTTP.name(),"example.proxy.com",3129);
etClient = new ETClient(configuration, etProxy);
} catch (ETSdkException e) {
e.printStackTrace();
}
}
return etClient;
}