0
I’m integrating Zenvia to text a system.
I use the script below, second documentation.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api-rest.zenvia.com/services/send-sms");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"sendSmsRequest\": {
\"from\": \"Remetente\",
\"to\": \"555199999999\",
\"schedule\": \"2014-08-22T14:55:00\",
\"msg\": \"Mensagem de teste\",
\"callbackOption\": \"NONE\",
\"id\": \"002\",
\"aggregateId\": \"1111\",
\"flashSms\": false
}
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: Basic YWRtaW46YWRtaW4=",
"Accept: application/json"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
However, even filling the data with the real ones, the return is always false
.
The same happens if I use the script below:
$url = 'https://api-rest.zenvia.com/services/send-sms';
$data = array(
"from" => "Remetente",
"to" => "555199999999",
"schedule" => "2014-08-22T14:55:00",
"msg" => "Mensagem de teste",
"callbackOption" => "NONE",
"id" => "002",
"aggregateId" => "1111",
"flashSms" => false
);
$options = array(
'http' => array(
'method' => 'POST',
'content' => json_encode( $data ),
'header'=> "Content-Type: application/json\r\n" .
"Authorization: Basic YWRtaW46YWRtaW4=\r\n" .
"Accept: application/json\r\n"
)
);
$context = stream_context_create( $options );
$result = file_get_contents( $url, false, $context );
echo "<pre>";
var_dump($result);
Am I doing something wrong? Or forgetting something ?
Some configuration on my server might be "blocking" something ?
Have you tried taking r n off the headlines.
– Inkeliz