$r->addPlayText('Thats an invalid input');
                 }
             }
         }
     }
 } else {
     if ($_SESSION['next_goto'] == 'DialMenu') {
         $r->addPlayText('Place Details');
         $r->addHangup();
     } else {
         if ($_REQUEST['event'] == 'Record' && $_SESSION['next_goto'] == 'Record_Status') {
             //recorded file will be come as  url in data param
             //print parameter data value
             $r->addPlayText('your recorded audio is ');
             $_SESSION['record_url'] = $_REQUEST['data'];
             $r->addPlayAudio($_SESSION['record_url']);
             $r->addPlayText('Going back to main menu');
             $url = "https://www.google.com/speech-api/v2/recognize?output=json&lang=en_US&key=AIzaSyA89KWhdKtIWJ38pz8CuK5HDgiB4Uum3Ak";
             $data = file_get_contents($_SESSION['record_url']);
             $r = POST($url, $data);
             $results = explode("\n", $r);
             foreach ($results as $result) {
                 $object = json_decode($result, true);
                 if (isset($object['result']) == true && count($object['result']) > 0) {
                     $_SESSION['location'] = $object['result'][0]['alternative'][0]['transcript'];
                     break;
                 }
             }
             $_SESSION['next_goto'] = 'Menu1';
         } else {
             if ($_SESSION['next_goto'] == 'Dial1_Status') {
Example #2
0
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
                curl_setopt($ch, CURLOPT_POST, 1);
                $result = curl_exec($ch);
            }
        }
    } elseif ($choice == "2") {
        //get friend's story
        $result = mysqli_query($conn, "SELECT * FROM audio WHERE user_id IN ( SELECT bro_id FROM friends  WHERE user_id={$userid} UNION SELECT user_id FROM friends WHERE bro_id={$userid} ) ORDER BY timestamp DESC; ");
        $row_cnt = $result->num_rows;
        if ($row_cnt == 0) {
            $r->addPlayText("Sorry. There are no new stories to play right now ");
        }
        while ($arrayResult = mysqli_fetch_assoc($result)) {
            $r->addPlayAudio($arrayResult['url']);
            $result = mysqli_query($conn, "INSERT INTO listen (user_id,audio_id) VALUES ({$userid},'" . $arrayResult['id'] . "')");
        }
    } elseif ($choice == "3") {
        $r->addPlayText("Thank you for calling audio chat ");
        $r->addHangup();
        //end call
        $r->send();
        exit;
    } else {
        $cd->addPlayText(" invalid input. Press 1 to broadcast new story , 2 to listen to friends , 3 to exit ");
        $r->addCollectDtmf($cd);
    }
} elseif (isset($_REQUEST['event']) && $_REQUEST['event'] == 'Record') {
    $url = $_REQUEST['data'];
    $no = $_REQUEST['cid'];