Translate command-line cURL to PHP
I have a working cURL request I want to translate to PHP code:
curl \
-X POST \
-u live_abcdefg: \
-d '{
"recipient": {
"address": "[email protected]"
}
}' \
https://api.sendwithus.com/api/v1/drip_campaigns/abcdefgh/activate
Here is the PHP code I'm trying:
<?php
$theurl = "https://api.sendwithus.com/api/v1/drip_campaigns/abcdefgh/activate";
$ch = curl_init($theurl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // -X
curl_setopt($ch, CURLOPT_POSTFIELDS, '{ "recipient": { "address": "[email protected]" } }'); // -d
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'live_abcdefg:'); // -u
$response = curl_exec($ch);
var_dump($response); // prints bool(true)
?>
EDIT: Sendwithus (the app that I'm sending requests to) shows that the second request didn't come through (second recipient [email protected] wasn't saved).
What am I doing wrong?
What can I change in the PHP code to start debugging this issue?