How to make a post request to the api

RebeccaH946
Rookie
0 Votes

Am trying to make a post request but am getting an error, anyone with an idea on what am not writing correct in my code snippet:

 

<?php
$request = new HttpRequest();
$request->setUrl('https://api.cc.email/v3/account/email');
$request->setMethod(HTTP_METH_POST);
$access_token = '7a8f8fca-8f2e-42de-9de7-b78c59c990de';

$request->setHeaders(array(
'Authorization' => 'Bearer {$access_oken}',
'Content-Type' => 'application/json'
));

$request->setBody('{
"email_address": "muytaba@yahoo.com"
}');

try {
$response = $request->send();

echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

1 REPLY 1
raleighb3
Marketing Legend
0 Votes

 

...Authorization' => 'Bearer {$access_oken}'...

Resources
Developer Portal

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

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up

Polls
How confident are you about the effectiveness of your current marketing strategy?

Top Choice: Not confident at all (70%)