fans and counting

api FanBridge API - Join the fan list

This example shows you how to add subscribers to a fan list using the subscriber/add API method.

Example code

You can include the PHP FanBridge API SDK library to improve the connection handling between your site and the FanBridge API platform.

Important: We will assume here that you already have an access Token and Secret key pair. If you don't know how to get them, please refer to the Connecting section.
Download this example

<?php

// Required files
require "fanbridge_api.php";

// Initialization
$fanbridge_api = new Fanbridge_Api(array(
	'secret' => $secret,
	'token' => $token));

try
{
	// Invokes the FanBridge API
	$response = json_decode($fanbridge_api->call(
		'subscriber/add',
		array(
			'email' => 'subscriber@email.com')));
}
catch (Fanbridge_Api_Exception $e)
{
	// Your code...
}
Now, you can check $response->id to know the new subscriber ID.