The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

authentication issues

Highlighted
Occasional Participant

authentication issues

Hi,

I have read most ( maybe all) post regarding authentication issues but still was unable to  make mine working

At this point I am assuming there is something wrong with my API key or account settings as I am unable to login directly using

   https://api.constantcontact.com/ws/customers/bruncon/contacts/

 

The server is asking for username and password  which I provided ..but no luck

 

I have also tried to construct an URL such as

 

https://api.constantcontact.com/ws/customers/bruncon/contacts/MYAPYKEY%USERNAME:PASSWORD

 

still no luck

 

Could someone please take a look at my API key and/or settings ?

USERNAME: bruncon

 

My ultimate goal is to use the following code

 

<?php

session_start();

include_once('scripts/constantcontact/ConstantContact.php');

$username = 'bruncon';
$apiKey = 'MYAPIKEY';
$consumerSecret = 'MYSECRET';
$consumerPassword = 'MYPASSWORD';

$Datastore = new CTCTDataStore();
$DatastoreUser = $Datastore->lookupUser($username);

 

if($DatastoreUser){

// $ConstantContact = new ConstantContact('oauth', $apiKey, $DatastoreUser['username'], $consumerSecret);
$ConstantContact2 = new ConstantContact('basic', $apiKey, $DatastoreUser['username'], $consumerPassword);
$ContactLists = $ConstantContact2->getLists();
}
echo $ContactLists ;
print_r($ContactLists);
?>

5 REPLIES 5
Highlighted
Employee

Re: authentication issues

Hey,

 

Try changing this line:

$ConstantContact2 = new ConstantContact('basic', $apiKey, $DatastoreUser['username'], $consumerPassword);

 to:

$ConstantContact2 = new ConstantContact('basic', $apiKey, $username, $consumerPassword);

 or just enter the information instead of putting variables:

$ConstantContact = new Constantcontact("basic", "your apikey", "your username", "your password");

$myLists = $ConstantContact->getLists();

foreach($myLists['lists'] as $list)
{
  echo $list->name;
}

also an example on how to navigate and get the names of all lists.

 

Please let me kow if this helps.

Ryan Davis
Quality Engineer
Highlighted
Occasional Participant

Re: authentication issues

Hi Ryan,

Thanks for your prompt response

Unfortunately it did not work - theerror message is

 

"OAuth Exception: Username bruncon not found in datastore"

 

 

 

Highlighted
Occasional Participant

Re: authentication issues

Hi Ryan

I was able to get the lists by going to

https://api.constantcontact.com/ws/customers/bruncon/lists

and login with APIKEY%USERNAME and PASSWORD

However I am still struglying to do it programatically

the lookupuser function is returning "OAuth Exception: Username bruncon not found in datastore"

and using the simplyfied code below is not returning anything ( in fact it breaks the page and all I get is

" [ <![CDATA[ ) [_never_allowed_regex:protected] => Array ( [javascript\s*:] => [removed] [expression\s*(\(|&\#40;)] => [removed] [vbscript\s*:] => [removed] [Redirect\s+302] => [removed] ) ) [uni] => CI_Utf8 Object ( ) ) -->"

 

" ...


$ConstantContatact = new Constantcontact("basic", "your apikey", "your username", "your password");

$myLists = $ConstantContact->getLists();

foreach($myLists['lists'] as $list)
{
  echo $list->name;
}

.."

 

Thanks

Steven

Highlighted
Employee

Re: authentication issues

Hey,

 

The issue is that your trying to use oAuth credentials through a BASIC authentication.  With BASIC authentication, you are not generating a Valid access token which is why your validation is failing.  With BASIC authentication you use your standard credentials as in the above post.  

 

The example that I wrote up should work stand alone with no other programming including the session and the securet and the datastore.  The datastore is just an array that is held in session that would gather the information that is generated upon a user granting access to the account using oAuth.  

 

Are you trying to use BASIC authentication or oAuth?

Ryan Davis
Quality Engineer
Highlighted
Employee

Re: authentication issues

$ConstantContatact = new Constantcontact("basic", "your apikey", "your username", "your password");

 change your instance variable to:

 

$ConstantContact = new Constantcontact("basic", "your apikey", "your username", "your password");

 $ConstantContact is spelled incorrectly.  Other wise the basic authentication request looks good and should work.  Please let us know.

Andrew Weber
Associate Product Manager for EventSpot
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured