$result = curl_exec($ch); // Closing curl_close($ch); $json = json_decode($result, true); if ($json && $json['status'] == 'success') { switch ($json['type']) { case 'Play': $response->Play($json['msg']); $response->Redirect($next); break; case 'Sms': $response->Sms($json['msg']); $response->Redirect($next); break; case 'Dial': $response->Dial($json['msg']); $response->Redirect($next); break; case 'Hangup': $response->addHangup(); break; case 'Say': default: $response->Say($json['msg']); $response->Redirect($next); break; } } elseif ($json && $json['status'] != 'success') { switch ($json['type']) { case 'Play': $response->Gather(array('numDigits' => $numDigits, 'timeout' => 60))->Play($json['msg']);