cURL with array, only takes first value

0

my problem is that I am sending parameters through cURL to a GSM modem that I have ... with a chip to send text messages ... everything works fine, when when I go through an array with destinations it is when it fails. .. only send to the first element of the array and the others do not ... I do not know if something is missing or I have something left I have these codes:

curl.php

<?php

function Enviar($Mensaje,$Destino){
error_reporting(E_ALL);
ini_set('display_errors', 1);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://mi.modem.gsm.lol/sms.cgi');
curl_setopt($ch, CURLOPT_USERPWD, 'xxxx:xxxx');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, "Send=Send&max_digit=".$Mensaje."&sms_number=".$Destino);

$output = curl_exec($ch);

if($output === FALSE){
echo 'cURLL Error:'.curl_error($ch);
return FALSE;
}

curl_close($ch);
return TRUE;

//print_r($output);


}
?>

Send.php

    <?php
include 'curl.php';
$Destinos = array("xxxxxxxxx","xxxxxxxxx","xxxxxxxxx");
//var_dump($Destinos);
$Mensaje = "Mensaje de prueba desde el servidor...";

$NDestinos = count($Destinos);

for($i=0;$i<$NDestinos;$i++){
$respuesta = Enviar($Mensaje,$Destinos[$i]);

if($respuesta){
echo "enviado ".$Destinos[$i]."<br>";
}else{
echo "no envia";
}
}

?>

thanks in advance!

    
asked by Alf 20.11.2017 в 17:10
source

0 answers