1

we are in the process of trying to interface our Application with SalesForce/ExactTarget.

We are unsure about the current state and version of Fuel-SDK-Java: On https://code.exacttarget.com/apis-sdks/fuel-sdks/java/getting-started-with-the-java-sdk.html there is a link to http://salesforce-marketingcloud.github.io/FuelSDK-Java/ The title of this page says "Fuel Java SDK 1.1.0-pre1 API" (please note the "pre1").

On the Doc for ETSubscriber there is a method unsubscribe(): http://salesforce-marketingcloud.github.io/FuelSDK-Java/com/exacttarget/fuelsdk/ETSubscriber.html#unsubscribe(com.exacttarget.fuelsdk.ETList)

There is no further link how to obtain/use the Fuel-SDK-Java, however I found https://github.com/salesforce-marketingcloud/FuelSDK-Java

The instructions there say to use dependency "com.exacttarget/fuelsdk/1.1.0" which I did and it works. However the ETSubscriber I get there does not have a unsubscribe() method. When I check the source, I see that the method has been commented out. When I check the repository, there is no 1.1.0 tag or branch. The unsubscribe method is not in the repository (not even commented out) neither in master not in latest tag 1.0.3 nor in 1.0 branch.

Can you please advise which is the "current version" to use and confirm that "removing from a publication list" is supported in it ?

Cheers, Tom.

0

Solution: A new class ETSubscriberList has been created that was missing from the package. This new list is used for disassociating a user from a list.

An object of ETSubscriberList needs to be created whose id should be the ID of the subscription list from which we need to remove the subscriber. Now, set the status of ETSubscriberList object to delete and action as update. ETSubscriber object has a member that takes list of ETSubscriptionList. Create a ETSubscriber object with the email address and key of the subscriber which needs to be unsubscribed. Add the ETSubscriberList object to ETSubscriber object. And call an update response passing a list of ETSubscriber. And bingo, when you check on UI on the concerned list, the subscriber is gone.

See file BeginTest.java for a sample code for this solution.

0

package com.salesforce.testashok;

import java.util.ArrayList; import java.util.Arrays; import java.util.List;

import com.exacttarget.fuelsdk.ETClient; import com.exacttarget.fuelsdk.ETConfiguration; import com.exacttarget.fuelsdk.ETEmail.Type; import com.exacttarget.fuelsdk.ETFilter; import com.exacttarget.fuelsdk.ETList; import com.exacttarget.fuelsdk.ETResponse; import com.exacttarget.fuelsdk.ETSdkException; import com.exacttarget.fuelsdk.ETSoapObject; import com.exacttarget.fuelsdk.ETSubscriber; import com.exacttarget.fuelsdk.ETSubscriber.Status; import com.exacttarget.fuelsdk.ETSubscriberList; import com.exacttarget.fuelsdk.internal.SubscriberList;

public class BeginTest {

public static void main(String[] args) throws ETSdkException {

    ETConfiguration configuration = new ETConfiguration();
    configuration.setClientId("your client id");
    configuration.setClientSecret("your client secret");

    ETClient client = new ETClient(configuration);

    /**
     * creating a subscriber
     */
    /*ETSubscriber subscriber = new ETSubscriber();
    subscriber.setClient(client);
    subscriber.setEmailAddress("email address of subscriber");
    subscriber.setKey("distinct key of subscriber");
    subscriber.setStatus(Status.ACTIVE);
    subscriber.setPreferredEmailType(Type.HTML);

    List<ETSubscriber> craeteSubscriberList = new ArrayList<ETSubscriber>();
    craeteSubscriberList.add(subscriber);       

    ETResponse<ETSubscriber> createSubscriberResponse = (ETSubscriber.create(client,craeteSubscriberList));
    System.out.println(createSubscriberResponse);*/

    /**
     * creating a subscription list  
     */
    /*ETList etList = new ETList();
    etList.setName("TestList3");
    etList.setClient(client);

    List<ETList> craeteSubscriptionList = new ArrayList<ETList>();
    craeteSubscriptionList.add(etList);     

    ETResponse<ETList> createSubscriptionListResponse = (ETList.create(client,craeteSubscriptionList));
    System.out.println(createSubscriptionListResponse);*/

    /**
     * adding a subscriber to subscription list
     */
    //define a created subscriber
    /*ETSubscriber subscriber = new ETSubscriber();
    subscriber.setClient(client);
    subscriber.setEmailAddress("email address of subscriber");
    subscriber.setKey("distinct key of subscriber");

    //define a created list
    ETList etList = new ETList();
    etList.setId("59483");
    etList.setName("TestList1");
    etList.setClient(client);
    etList.getSubscribers().add(subscriber);

    List<ETList> updateSubscriptionList = new ArrayList<ETList>();
    updateSubscriptionList.add(etList);     

    ETResponse<ETList> updateSubscriptionListResponse = (ETList.update(client,updateSubscriptionList));
    System.out.println(updateSubscriptionListResponse);*/

    /**
     * removing a subscriber from subscription list
     */
    //define a created subscriber
    ETSubscriber subscriber = new ETSubscriber();
    subscriber.setEmailAddress("email address of subscriber");
    subscriber.setKey("distinct key of subscriber");

    //craete a ETSubscriberList taht will associate a user to a list and will delete a specific subscriber from a specific list 
    ETSubscriberList etSubscriberList = new ETSubscriberList();
    etSubscriberList.setId("your list id");
    etSubscriberList.setStatus(Status.DELETED);
    etSubscriberList.setAction("update");

    subscriber.getLists().add(etSubscriberList);

    List<ETSubscriber> updateSubscriberList = new ArrayList<ETSubscriber>();
    updateSubscriberList.add(subscriber);   

    ETResponse<ETSubscriber> updateSubscriberResponse = (ETSubscriber.update(client,updateSubscriberList));
    System.out.println(updateSubscriberResponse);
}

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.