Java

Contact Importer for Java

Additionally to our simple widget integration,
CloudSponge offers an API for Java.

Get Started

Create your CloudSponge account and tell us your domain. If it’s your development environment you’ll get a CloudSponge Key for free.

Install

If you’re using Maven, add to you pom.xml:

<dependency>
  <groupId>com.cloudsponge</groupId>
  <artifactId>cloudsponge</artifactId>
  <version>1.0-RC2</version>
</dependency>

If you’re not using Maven, download the single jar or the jar with all included dependencies and add it your project.

Usage

CloudSpongeApiFactory factory = new CloudSpongeApiFactoryImpl("DOMAIN_KEY", "DOMAIN_PASSWORD");

CloudSpongeApi<UserConsent> cloudSponge = factory.create(ContactsService.GMAIL);
// For AOL use:
// final CloudSpongeApi<ImportResponse> cloudSponge = factory.create(ContactsService.AOL);
// cloudSponge.userName("me").userPassword("test").beginImport();

try {
  UserConsent consent = cloudSponge.beginImport();
  // Manually open the consent page in a browser window to continue with the import
  System.out.println("Copy and paste the following URL into your favorite browser to continue with the import:");
  System.out.println(consent.getUrl());

  // Waiting for consent...
  ProgressEvents progress = cloudSponge.getImportProgress();
  while (!progress.isDone()) {
    progress = cloudSponge.getImportProgress();
    Thread.sleep(1000);
  }

  Event completeEvent = progress.getEvent(EventType.COMPLETE);
  if (completeEvent.getStatus() == EventStatus.ERROR) {
    System.out.println("Error: " + completeEvent.getValue());
  } else {
    UserContacts userContacts = cloudSponge.fetchContacts();
    Contact owner = userContacts.getOwner();
    System.out.println(owner);
    for (Contact contact : userContacts.getContacts()) {
      System.out.println(contact);
    }
  }
} finally {
  cloudSponge.close();
}

CloudSponge Proxy URL

The CloudSponge API Java Wrapper also includes an implementation of a Proxy URL for branding the user authentication process. For more the details, click here.

For using the Proxy URL Servlet, just add it to your web.xml file:

<servlet>
  <servlet-name>CloudSponge URL Proxy</servlet-name>
  <servlet-class>com.cloudsponge.CloudSpongeProxyServlet</servlet-class>
</servlet>
<servlet-mapping>
  <servlet-name>CloudSponge URL Proxy</servlet-name>
  <url-pattern>URL_PATTERN</url-pattern>
</servlet-mapping>

Other languages than Java

Don’t want to use Java? Not a problem! CloudSponge offers API for several languages:
PHPJavaRuby.NetColdFusion – or even a Do-It-Yourself Approach, which uses a REST API to return Contacts in JSON format.

Try CloudSponge for free in your
testing environment

Get Started

Have a questions or prefer a guided tour?
Schedule a consultation with our Founder.