Logging into the new API v4.0

by Andrew Kanes on March 18, 2010 · 2 comments

This past week, Bronto was proud to introduce many new features in accordance with our Spring 2010 Release. The release also included a new version of the API (version 4). While the old API (legacy version 3) is not going away, the new version is the one Bronto will be concentrating on and developing new features for. The new API will give you access to more Bronto objects and improved filtering of those objects. Along with the improvements made in the new API are a few changes. One of the main changes is how you authenticate or log into the API. You are no longer required to create an API user with the appropriate permissions. Instead, you will create an API token. Once you have been authenticated, you will be returned a sessionId that you will use for the rest of you session.

Creating a token

To create a token, go to Home->Settings->Data Exchange and click Add Access Token. The token can be limited in the actions it can perform, such as read, write, or send. Hence, you can configure each token you create and allow it do any one of those actions, a combination, or all of them.
Create token screen shot

Some Example Code (PHP and JAVA AXIS)

Below is some example code you can use to get an idea of how to login to the new API.

PHP


/*
This example script will connect to the API and authenticate a session.
Be sure to replace the "ADD YOUR API TOKEN HERE" text with a working
API Token.
*/

ini_set("soap.wsdl_cache_enabled", "0");
date_default_timezone_set('America/New_York');


$wsdl = "https://api.bronto.com/v4?wsdl";
$url = "https://api.bronto.com/v4";


$client = new SoapClient($wsdl, array('trace' => 1, 'encoding' => 'UTF-8'));
$client->__setLocation($url);


$token = "ADD YOUR API TOKEN HERE";
$sessionId = $client->login(array("apiToken" => $token))->return;
$client->__setSoapHeaders(array(new SoapHeader("https://api.bronto.com", 'sessionId', $sessionId)));

JAVA AXIS


/**
* This example program will connect to the API and authenticate a session.
*/

package com.bronto;

import org.apache.axis.client.Stub;

import com.bronto.api.objects.BrontoSoapApi;
import com.bronto.api.objects.BrontoSoapApiImplService;
import com.bronto.api.objects.BrontoSoapApiImplServiceLocator;
import com.bronto.api.objects.StringValue;

public class TestLoginBronto {
private static final String API_TOKEN = "ADD YOUR API TOKEN HERE";

public static void main(String args[]) throws Exception {
BrontoSoapApiImplService locator = new BrontoSoapApiImplServiceLocator();
BrontoSoapApi api = locator.getBrontoSoapApiImplPort();

// Login
String sessionId = api.login(API_TOKEN);
if (sessionId == null) {
System.out.println("Login failed.");
return;
}
((Stub)api).setHeader(locator.getServiceName().getNamespaceURI(), "sessionId", sessionId);

System.out.println("Login was successful.");
}
}

Lots More

With its expanded functionality and improved design, the new API provides many exciting opportunities to integrate with your systems outside of Bronto. We hope you enjoy the new API as much as we enjoy bringing it to you.

Andrew Kanes
Support Engineer at Bronto

Related posts:

  1. Create a Header Without Logging into Bronto Did you know you can now create headers and footers...
  2. Using readDeliveries In API Version 4 In version 4 of the API, we have updated the...
  3. Personalize Your Contacts, Storing Field Data With The API OK, so your integration is running. You’re adding contacts at...

{ 2 trackbacks }

Using the New readContacts Function
04.08.10 at 2:29 pm
Using The apiToken Functions In Version 4
06.17.10 at 4:30 pm

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: