OP
05/16/2024, 12:26 PMphp
$phoneNumberId = "123456"; // Replace with actual phone number ID
$authToken = "XXXXXXXXXXXXXXXXXXXXX"; // Replace with actual token
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.vapi.ai/phone-number/{$phoneNumberId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer {$authToken}",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$responseData = json_decode($response, true);
// Print the entire response for debugging
echo "<pre>";
print_r($responseData);
echo "</pre>";
// Check if 'serverUrl' is present in the response
if (isset($responseData['serverUrl'])) {
echo "Server URL: " . $responseData['serverUrl'];
} else {
echo "Server URL is not present in the response.";
}
}