Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/02/2019, 19:21
Brujo2
 
Fecha de Ingreso: agosto-2006
Mensajes: 32
Antigüedad: 17 años, 8 meses
Puntos: 1
Respuesta: Problema con una API Rest de Sinch en PHP

Ya lo solucione:

Código PHP:
<?
$data
=array('from' => 'Oso''to' => array('57xx'), 'body' => 'Hola este es un mensaje de prueba' );
$ch curl_init();
curl_setopt($chCURLOPT_URL"https://sms.api.sinch.com/xms/v1/xxxx/batches");
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
curl_setopt($chCURLOPT_POSTtrue);
curl_setopt($chCURLOPT_CUSTOMREQUEST"POST");
curl_setopt($chCURLOPT_POSTFIELDS,  json_encode($data));
curl_setopt($chCURLOPT_HEADERtrue);
    
curl_setopt($chCURLOPT_HTTPHEADER, array(
    
"Authorization: Bearer xxxxx",
    
"Content-Type: application/json",
  ));
$res curl_exec($ch);
print_r($res);
//var_dump(curl_getinfo($ch));
if(curl_errno($ch))
{
    echo 
'Curl error: ' curl_error($ch);
}

curl_close($ch);
?>
-Agregue un array() adicional en "to"
-convertí a Json con la función json_encode
-Posdata: Las "xxx" eran la llave y el numero de cuenta