How can I get account id and clientFolderId in icontact API

My question is specific to iContact API. I registered the application and received the API identifier. But I can not find accountId and clientFolderId.

See link below:

http://developer.icontact.com/documentation/request-your-accountid-and-clientfolderid/ The page above "Running a GET on an Account Resource". How can I do this to get the account id and client database.

+5
source share
4 answers

The easiest way I found: Go to the sandbox or your real iContact account, go to the "Contacts → registration forms" section in the main menu, then create only any form, click on the HTML view and you will find the account identifier is .

+2
source

This is my complete code to get the account id and client folder id, thanks to Carlos Duran for getting some of my code problems:

/* iContact LIVE * /
$GLOBALS['iContact_settings'] = array(
    'apiUrl'   => 'https://app.icontact.com',
    'apiPage'  => '/icp/a/',
    'username' => 'username',
    'password' => 'password',
    'appId'    => 'appId'
);
/* iContact SANDBOX */
$GLOBALS['iContact_settings'] = array(
    'apiUrl'   => 'https://app.sandbox.icontact.com',
    'apiPage'  => '/icp/a/',
    'username' => 'username-beta',
    'password' => 'password',
    'appId'    => 'appId'
);
/**/


$icontact_url  = $GLOBALS['iContact_settings']['apiUrl'] . $GLOBALS['iContact_settings']['apiPage'];
$icontact_page = $GLOBALS['iContact_settings']['apiPage'];
$icontact_headers = array( 
    "GET ".$icontact_page." HTTP/1.0",
    "Accept: text/xml",
    "Content-Type: text/xml",
    "API-Version: 2.2",
    "API-AppId: " .    $GLOBALS['iContact_settings']['appId'],
    "API-Username: " . $GLOBALS['iContact_settings']['username'],
    "API-Password: " . $GLOBALS['iContact_settings']['password']
);


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $icontact_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $icontact_headers);

$data = curl_exec($ch);
curl_close($ch);

$account_id = "";
if (($pos=strpos($data,"<accountId>"))!==false){
    $account_id = substr($data, strlen("<accountId>")+$pos);
    if (($pos=strpos($account_id,"<"))!==false){
        $account_id = substr($account_id, 0, $pos);
    }
}


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $icontact_url ."$account_id/c/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $icontact_headers);

$data = curl_exec($ch);
curl_close($ch);

$client_folder_id = "";
if (($pos=strpos($data,"<clientFolderId>"))!==false){
    $client_folder_id = substr($data, strlen("<clientFolderId>")+$pos);
    if (($pos=strpos($client_folder_id,"<"))!==false){
        $client_folder_id = substr($client_folder_id, 0, $pos);
    }
}

I just switched to JSON, better.

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $icontact_url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_HTTPHEADER, $icontact_headers);

$data = curl_exec($handle);
curl_close($handle);

$decoded = json_decode($data);
$account_id = $decoded->accounts[0]->accountId;

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $icontact_url ."$account_id/c/");
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_HTTPHEADER, $icontact_headers);

$data   = curl_exec($handle);
curl_close($handle);

$decoded = json_decode($data);
$client_folder_

id = $decoded->clientfolders[0]->clientFolderId;

And use:

"Accept: application/json",
"Content-Type: application/json",

Instead of the text/xmlabove.

+2
source

API iContact - , , .

, , - PHP script cUrl

     $url = "https://app.sandbox.icontact.com/icp/a/";
     $page = "/icp/a/";
     $headers = array( 
        "GET ".$page." HTTP/1.0",
        "Accept: text/html",
        "Content-Type: text/html",
        "API-Version: 2.2",
        "API-AppId: yourapiappid",
        "API-Username: yourapiusername",
        "API-Password: yourappidpassword"
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $data = curl_exec($ch);

, URL- script!

, .

" ".

+1

This PHP iContact API is pretty useful https://github.com/icontact

0
source

All Articles