Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
calltest
:
event.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php // Vonage sends a JSON payload to your event endpoint, so read and decode it $request = json_decode(file_get_contents('php://input'), true); //$request = $_REQUEST; echo '<pre>'; print_r($request); echo '</pre>'; // Work with the call status if (isset($request['status'])) { switch ($request['status']) { case 'ringing': record_steps("UUID: {$request['conversation_uuid']} - ringing."); break; case 'answered': $arrData = '{ "to":[{"type": "phone","number": "918758607477"}], "from": {"type": "phone","number": "918866897945"}, "answer_url": ["https://hogsandbbqs.co.uk/calltest/answer-2.json"], "machine_detection":"continue" }'; $sendSMS = sendSMS('https://api.nexmo.com/v1/calls', $arrData); $sendSMSArr = json_decode($sendSMS, true); echo '<pre>'; print_r($sendSMSArr); echo '</pre>'; break; case 'complete': record_steps("UUID: {$request['conversation_uuid']} - complete."); break; default: break; } } function record_steps($message) { file_put_contents('./call_log.txt', $message.PHP_EOL, FILE_APPEND | LOCK_EX); } function sendSMS($url, $jsonData) { $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2MjIyMjkyMzAsImV4cCI6MTYyMjI1MDgzMCwianRpIjoiSUNmQzdWWHp3bUs1IiwiYXBwbGljYXRpb25faWQiOiJiYzVjMzQ2Mi0zODgxLTQ0NzItYWFjNi0wYzkzOGZlMmMyYWYifQ.tjafXEXjVF9_IYt3paWqBtllIEdGv8OjdnWGuwByBwrjONBs1gU1xVQI2nN9upL5vWYD-20cnAg9nDaYrQaLB47-4Tnw_X12r3Ys0DlNcZy8pE3Vv8V2bdK-4UVVt_6FdrlI9TnMP3klJBGs7VX8WZZLKIRy3ulheGybJPmA2VB-nSpGCBgYtODd22U-roXSbsW78RXTSZAvIMTd9lEDaA5MYcaSH9yzAaGU-n397B6IAUsFK1NxIPpQ5_Zl5yRVZHgY_MX5yJu8tsQC-9HCvrs64c2S0OG_iC6fVONK1eWA7aL-4HfKSb_DZm-R2WtEkrqgQjiNEX65VyHt_d527w'; try { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $jsonData, CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'Authorization: Bearer '.$token ), )); $response = curl_exec($curl); curl_close($curl); } catch(Exception $e){ throw new Exception("Invalid URL",0,$e); } return $response; } ?>