-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSendCall.php
35 lines (31 loc) · 950 Bytes
/
SendCall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// Ejecutar: composer require guzzlehttp/guzzle:*
require'vendor/autoload.php';
$headers=array(
'Content-Type'=>'application/x-www-form-urlencoded',
'Accept'=>'application/json',
);
$client= new \GuzzleHttp\Client();
// Define la matriz del cuerpo de la solicitud.
$request_body = array(
"client"=>"AQUI_SU_CLIENT",
"key"=>"AQUI_SU_KEY",
"phone"=>"AQUI_EL_NUMERO_DE_CELULAR",
"message"=>"AQUI_EL_MENSAJE_A_ENVIAR",
"voice"=>"AQUI_TIPO_DE_VOZ",
"retries"=>"AQUI_NUMERO_DE_INTENTOS",
"leave-voicemail"=>"false",
"audio-code"=>"AQUI_ID_AUDIO",
);
try{
$response=$client->request('POST','https://www.onurix.com/api/v1/call/send',array(
'headers'=>$headers,
'form_params'=>$request_body,
)
);
print_r($response->getBody()->getContents());
}
catch(\GuzzleHttp\Exception\BadResponseException $e){
// Manejar excepciones o errores de API
print_r($e->getMessage());
}