File "answer.php"

Full Path: /var/www/vhosts/hogsandbbqs.co.uk/httpdocs/calltest/answer.php
File size: 1.95 KB
MIME-type: text/x-php
Charset: utf-8

<?php
    $arrData = '{
            "to":[{"type": "phone","number": "918758857048"}],
            "from": {"type": "phone","number": "918758607477"},
            "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);
    function sendSMS($url, $jsonData) {
    
        $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE2MjI0ODQxODIsImV4cCI6MTYyMjUwNTc4MiwianRpIjoiTUIzTm9ueTVKc2EwIiwiYXBwbGljYXRpb25faWQiOiJiYzVjMzQ2Mi0zODgxLTQ0NzItYWFjNi0wYzkzOGZlMmMyYWYifQ.Reuz7oPO5vR0yFPuFmEETGKdbyIPfh4e75atKoaqdF9pOh6CiDZtcJOp4GTRNPA8SFlDh9tUwwN0bxOBPE5dytpYtI4r77u9U3Y0YstjXEjpeARlRGZFS5JNHAs0pxpxCHiAU5KVjvSz4HjBDJcyavx7NCCeUIb4Vmyurp-pkn4KtpGAwsIXGuzOW3p9lRJwIiXf5Ow0hW4866_ErdRm_kocqcHHB7CWDf40pBBN6LAXFl9ztI7LiK1Z7bHvmI9OnzNyZGmQ55MFktRhXmCy5VlgK4Jryu21yaBOMfBVqshf4zIeNBH3WuI510ieQvD25aCDN39NAula2SXOgaXXVg';
     
        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;
    }
echo '[    
        {
            "action": "conversation",
            "name": "test-conversation"
        } 
    ]';
?>