1

I have been trying to get the list of subscribers from drip account. I am trying to do so with the curl php I am unable to do so.

Official example

curl -H 'User-Agent: Your App Name (www.yourapp.com)' \
  -u f4ff6a200e850131dca1040cce1ee51a: \
  -d status=active \
  https://api.getdrip.com/v2/9999999/campaigns

My Code

$TOKEN='f69444e104aea5b77a969bb313852dc1';
$ch = curl_init('https://api.getdrip.com/v2/1186104/subscribers');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'TestApp (laflechee@gmail.com)');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'Content-Type: application/json',
  'Authorization: Bearer ' . $TOKEN
));
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

echo $data;
halfer
  • 19,824
  • 17
  • 99
  • 186
Nitin Johnson
  • 330
  • 2
  • 16

1 Answers1

0

I am adding a new subscriber in drip with the below code. You can follow it.

$ch = curl_init();
//YOUR-ACCOUNT-ID replace it with your account id
curl_setopt($ch, CURLOPT_URL, 'https://api.getdrip.com/v2/YOUR-ACCOUNT-ID/subscribers');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$data = array(
                'subscribers' => array(
                    array( 
                        'email'      => 'myemail@domain.com',
                        'first_name' => 'Mohsin',
                        'last_name'  => 'raza' 
                    ),
                ),
            );
$post = json_encode($data);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
//YOUR-API-TOKEN-HERE replace it with your api-token
curl_setopt($ch, CURLOPT_USERPWD, 'YOUR-API-TOKEN-HERE' . ':' . '');

$headers = array();
//replace with your app name and registered domain with drip account
$headers[] = 'User-Agent: YOUR-APP-NAME (www.your-domain.com)';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result; 
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Mohsin Raza
  • 488
  • 1
  • 6
  • 12