Sarv.com

PHP

Choose Language

Get available Did Number

Info! This is Beta version, if you have any problem in using API, please mail us at [email protected]

https://manage.sarv.com/api/telephony/getTelephonyNumber

Get all available Telephonic NUmber

Example Call


<?php
    try {    
    $data = array('user_id' => '01234567', 'token' => 'abcXYZ');
    $finalData['data'] = json_encode($data);
    $url="https://manage.sarv.com/api/telephony/getTelephonyNumber";
    $handle = curl_init($url);
    curl_setopt($handle, CURLOPT_POST, true);
    curl_setopt($handle, CURLOPT_POSTFIELDS, $finalData);
    $responce=curl_exec($handle);
    curl_close($handle);
    $ARR_MSG = json_decode($responce, true);
    if ($ARR_MSG['msg'] != "success") {
    print_r($ARR_MSG);
        return;
    }
    /*
        Array
        (
            [msg] => "success"
            [data] => array(
                    0=>array(
                                [did_number]=>"9876543210",
                                [country]=>"IN",
                                [area]=>"ALL",
                                [did_type]=>"MOBILE",
                                [vanity_type]=>"REGULAR",
                                [vanity_cost]=>"0"
                            ),  ...)
        )
        */    
    } catch($e) {
        // Sarv errors are thrown as exceptions
        echo "A sarv error occurred: " . get_class($e) . " - " . $e->getMessage();
    }
?>

Example Success Response


Array
(
    [status] => "success"
    [data] => array(
                    0=>array(
                                [did_number]=>"9876543210",
                                [country]=>"IN",
                                [area]=>"ALL",
                                [did_type]=>"MOBILE",
                                [vanity_type]=>"REGULAR",
                                [vanity_cost]=>"0"
                            ),  ...)
)

Example Error Response


Array
(
    [status]=> "error"
    [msg_text]=> issue will be show here   
)

Parameters
user_id* string a valid Sarv User Id
token* string a valid token
* compulsory field
Return Value: Success
struct the results of getting all DID Number
msg string always success
data array [data] => array( 0=>array( [did_number]=>"9876543210", [country]=>"IN", [area]=>"ALL", [did_type]=>"MOBILE", [vanity_type]=>"REGULAR", [vanity_cost]=>"0" ), ...)
Means of Return Value 'country' key
IN India.
Means of Return Value 'area' key
ALL ALL
Means of Return Value 'did_type' key
MOBILE Mobile Number like 9876543210
TOLLFREE Tollfree like 18002000000
Means of Return Value 'vanity_type' key
REGULAR
VIP
SILVER
GOLD
PLATINUM
DIAMOND
Means of Return Value 'vanity_cost' key
1000 Cost of Number
Return Value: Error
struct the error results when attempt to getting DID Number Data
msg string error
msg_text string human readable message