我一直试图从滴水帐户中获取订阅者列表。我试图用curl php这样做我无法这样做。
官方示例
curl -H 'User-Agent: Your App Name (www.yourapp.com)' \
-u f4ff6a200e850131dca1040cce1ee51a: \
-d status=active \
https://api.getdrip.com/v2/9999999/campaigns
我的代码
$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;
答案 0 :(得分:0)
我正在使用以下代码在水滴中添加一个新订阅者。你可以关注它。
$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);