PHP code example of slowprog / getresponse-api2

1. Go to this page and download the library: Download slowprog/getresponse-api2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

slowprog / getresponse-api2 example snippets




$api = new GetResponseApi2('YOUR_API_KEY');

// Connection Testing
$ping = $api->ping();
var_dump($ping);

// Account
$details = $api->getAccountInfo();
var_dump($details);

// Campaigns
$campaigns 	 = (array)$api->getCampaigns();
$campaignIDs = array_keys($campaigns);
$campaign 	 = $api->getCampaignByID($campaignIDs[0]);
var_dump($campaigns, $campaign);

// Contacts
$contacts 	= (array)$api->getContacts(null);
$contactIDs	= array_keys($contacts);
$setName 	= $api->setContactName($contactIDs[0], 'John Smith');
$setCustoms	= $api->setContactCustoms($contactIDs[0], array('title' => 'Mr', 'middle_name' => 'Fred'));
$customs 	= $api->getContactCustoms($contactIDs[0]);
$contact 	= $api->getContactByID($contactIDs[0]);
$geoIP 		= $api->getContactGeoIP($contactIDs[0]);
$opens 		= $api->getContactOpens($contactIDs[0]);
$clicks 	= $api->getContactClicks($contactIDs[0]);

// Find the contact ID by using email ID and delete the contact
$contactEmail	= (array)$api->getContactsByEmail('EMAIL_ID');
$contactEmailID	= array_keys($contactEmail);
$deleteResponse	= $api->deleteContact($contactEmailID[0]);

var_dump($contacts, $setName, $setCustoms, $customs, $contact, $geoIP, $opens, $clicks);

// Blacklists
$addBlacklist = $api->addAccountBlacklist('[email protected]');
$getBlacklist = $api->getAccountBlacklist();
$delBlacklist = $api->deleteAccountBlacklist('[email protected]');
var_dump($addBlacklist, $getBlacklist, $delBlacklist);

// or JSON RPC with batch

$api = new GetResponseJsonRpc('YOUR_API_KEY');

$response = $api->batch()
    ->addContact('qwer', '[email protected]', 'asdf')
    ->addContact('asdf', '[email protected]', 'qwer')
    ->send();

var_dump($response);