Webex Teams

SDK for Java

Integrate Webex Teams into your Java applications quickly

Features

Integrate the Java SDK into server-side applications and use Webex Teams features directly in your Java applications.

Getting Started Guide

This guide will get you up-and-running with the Webex Teams Java SDK.

Overview

  • Create Webex Teams rooms
  • Post messages

Requirements

  • Java 1.6 or greater
  • This SDK requires the spark:all scope

Step 1: Register for a Webex Teams Account

Before using the SDK, you will need a Webex Teams account and a developer access token. If you haven't already, head on over to Webex Teams to create an account.

Once you have an account, log into this site to get your developer access token. You will need this token to authenticate API requests from the SDK.

Step 2: Install the Java SDK

The Java SDK is available on GitHub. Clone the repository and include the source files in your Maven project.

Step 3: Use the Java SDK

Create an Example Class

For this example, we'll create a very simple Example class and set the developer access token. You'll need this token to initialize the client.

import com.ciscospark.*;
import java.net.URI;

class Example {
  public static void main(String[] args) {
    // To obtain a developer access token, visit http://developer.webex.com
    String accessToken = "$YOUR_DEVELOPER_TOKEN";

Initialize the Webex Teams Client

Initialize the client and set the endpoint to the current Webex Teams API.

// Initialize the client
Spark spark = Spark.builder()
  .baseUrl(URI.create("https://api.ciscospark.com/v1"))
  .accessToken(accessToken)
  .build();

Create a New Space

Let's create a space. For now this space will only have you in it. You can always add more people later.

// Create a new room
Room room = new Room();
room.setTitle("Hello World");
room = spark.rooms().post(room);

Post a Message

Now that we have a new space, let's post a message to it.

// Post a text message to the room
Message message = new Message();
message.setRoomId(room.getId());
message.setText("Hello World!");
spark.messages().post(message);

Full Code

Compile and run the new class to see the SDK in action. Log into Webex Teams through one of the clients to see your new room and new message!

Here's the full code for the example class:

import com.ciscospark.*;
import java.net.URI;

class Example {
  public static void main(String[] args) {
    // To obtain a developer access token, visit http://developer.webex.com
    String accessToken = "$YOUR_DEVELOPER_TOKEN";

    // Initialize the client
    Spark spark = Spark.builder()
      .baseUrl(URI.create("https://api.ciscospark.com/v1"))
      .accessToken(accessToken)
      .build();

    // Create a new room
    Room room = new Room();
    room.setTitle("Hello World");
    room = spark.rooms().post(room);

    // Post a text message to the room
    Message message = new Message();
    message.setRoomId(room.getId());
    message.setText("Hello World!");
    spark.messages().post(message);
  }
}

Webex Teams

SDK for Java with E2EE New

Integrate Webex Teams into your Java applications quickly

Features

Integrate the Java SDK into server-side applications and use Webex Teams features directly in your Java applications.

  • Manage Webex Teams user accounts
  • Send messages and file attachments
  • Create spaces and manage space memberships
  • Create and manage webhooks
  • Use end-to-end encryption and decryption within the SDK
Getting Started Guide

This guide will get you up-and-running with the Webex Teams Java SDK.

The Java SDK described in this guide is currently pre-release software which is not available to all Webex Teams users. If you have any questions, or if you need help, please contact the Webex Developer Support team at devsupport@webex.com.

Overview

  • Create Webex Teams rooms
  • Post messages

Requirements

  • Java 1.8 or greater
  • This SDK requires the spark:all scope

Step 1: Register for a Webex Teams Account

Before using the SDK, you will need a Webex Teams account and a developer access token. If you haven't already, go ahead and create an account.

Once you have an account, log into this site to get your developer access token. You will need this token to authenticate API requests from the SDK.

Step 2: Install the SDK

Download the Java SDK and install the JAR in your local repository by running mvn clean install.

unzip webex-spark-java-sdk_1.0-SNAPSHOT.zip
cd spark-js-sdk/
mvn clean install

Now add the dependency to your project's pom.xml file:

<dependency>
    <groupId>com.cisco.spark.java</groupId>
    <artifactId>sdk</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

Step 3: Use the Java SDK

Create an Example Class

For this example, we'll create a very simple Example class and set the developer access token. You'll need this token to initialize the client.

import com.cisco.spark.java.sdk.*;
import java.net.URI;

class Example {
  public static void main(String[] args) {
    // To obtain a developer access token, visit http://developer.webex.com
    String accessToken = "$YOUR_DEVELOPER_TOKEN";

Initialize the Webex Teams Client

Initialize the client and set the endpoint to the current Webex Teams API.

// Initialize the client
Spark spark = Spark.builder()
  .baseUrl(URI.create("https://api.ciscospark.com/v1"))
  .accessToken(accessToken)
  .build();

Initialize the Webex Teams Client with End-to-End Encryption (E2EE)

By default, encryption and decryption of content stored in the Webex Cloud is handled by the Webex Teams API. To perform content encryption and decryption within the SDK, enable end-to-end encryption by initializing the client with .enableEndToEndEncryption(true):

// Initialize the client
Spark spark = Spark.builder()
  .baseUrl(URI.create("https://api.ciscospark.com/v1"))
  .accessToken(accessToken)
  .enableEndToEndEncryption(true)
  .build();

Create a New Space

Let's create a space. For now this space will only have you in it. You can always add more people later.

// Create a new room
Room room = new Room();
room.setTitle("Hello World");
room = spark.rooms().post(room);

Post a Message

Now that we have a new space, let's post a message to it.

// Post a text message to the room
Message message = new Message();
message.setRoomId(room.getId());
message.setText("Hello World!");
spark.messages().post(message);

Full Code

Compile and run the new class to see the SDK in action. Log into Webex Teams through one of the clients to see your new room and new message!

Here's the full code for the example class:

import com.ciscospark.*;
import java.net.URI;

class Example {
  public static void main(String[] args) {
    // To obtain a developer access token, visit http://developer.webex.com
    String accessToken = "$YOUR_DEVELOPER_TOKEN";

    // Initialize the client
    Spark spark = Spark.builder()
      .baseUrl(URI.create("https://api.ciscospark.com/v1"))
      .accessToken(accessToken)
      .build();

    // Create a new room
    Room room = new Room();
    room.setTitle("Hello World");
    room = spark.rooms().post(room);

    // Post a text message to the room
    Message message = new Message();
    message.setRoomId(room.getId());
    message.setText("Hello World!");
    spark.messages().post(message);
  }
}