i’m using PHP and CURL to send an email via rapidpro-sendgrid API and everything is done well but the response getted by the curl_exec() are a just blank and empty string (with double quotes).
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://rapidprod-sendgrid-v1.p.rapidapi.com/mail/send");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_ENCODING, "UTF-8");
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $messageField);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("accept: application/json","content-type: application/json","x-rapidapi-host: rapidprod-sendgrid-v1.p.rapidapi.com","x-rapidapi-key: *******"));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
加入讨论 - 在下面添加评论:
lol, really? so i was all this time thinking that was something wrong… oh fuck hahahaha. So, in this case, we can say: if th response get anything than an empty string, thats mean there something got wrong? I mean… i can validate the send by doing something like:
Is it safe to trust it? I really didn’t found anything in the docs that explain such a thing.
That’s to be expected! Any time an email is successfully send the request will simply respond with an empty 202 response.