User Tools

Site Tools


Sidebar

en:objects:cheapsms:functional:get_phone_number

get_phone_number

get_phone_number($service='ot',$operator='any',$country='0'); - get the number of available numbers.

the input Function accepts parameters:

  • $service – service for ordering. List of available services vk_0 - Vkontakte, ig_0 - Instagram, ok_0 - Odnoklassniki, vi_0 - Viber, other_0 - Other services.
  • $operator – mobile operator only for the Russian Federation: megafon, mts, beeline,tele2, any.
  • $country – country of the number, 0 - Russia, 1 - Ukraine, 2 - Kazakhstan, 3 - China, 4 - Philippines, 5 - Myanmar, 6 - Indonesia, 7 - Malaysia, 10 - Vietnam, 11 - Kyrgyzstan, 12 - USA, 13 - Israel, 14 - Hong Kong, 15 - Poland, 16 - England, 17 - Madagascar, 18 - Congo, 19 - Nigeria, 20 - Macau, 21 - Egypt, 23 - Ireland, 24 - Cambodia, 25 - Laos, 26 - Haiti, 27 - ivory coast, 28 - Gambia, 29 - Serbia, 30 - Yemen, 31 - South Africa, 32 - Romania, 34 - Estonia, 35 - Azerbaijan, 36 - Canada, 37 - Morocco, 38 - Ghana, 39 - Argentina, 40 - Uzbekistan, 41 - Cameroon, (optional, if not specified, the default number will be given according to the setting in the left menu).

    After testing, the function returns the result of its work to the script :
  • true – got a phone number
  • false – didn't get a phone number


    You can get the received phone number from the cheapsms->numbervariable. However, if we did not receive the phone number, the full response of the service can be obtained from the cheapsms->answervariable.

    The variable cheapsms->answer can be:

      NO_NUMBERS - no numbers
      NO_BALANCE - balance ended
      Possible error:
      ERROR_SQL - SQL server error
      BAD_KEY - invalid API key


    PHP example:

    <?php $xhe_host = "127.0.0.1:7010";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> cheapsms->".basename(__FILE__)."</font> <hr>";
     
    //set the API key for the service
    $cheapsms->api_key = '3161df9b1fe1ccb8cfd7dA91db765de8';
     
    //get phone number
    if(!$cheapsms->get_phone_number('other_0'))
    {
        while($cheapsms->answer == "NO_NUMBERS")
        {
            $cheapsms->get_phone_number('other_0');
            sleep(10);
        }
     
        if(strpos($cheapsms->answer, 'ACCESS_NUMBER') === false)
        {
           echo("answer $cheapsms->servis $cheapsms->answer <br>");
           $app->quit();
        }
    }
     
    //sms sent
    $cheapsms->set_status(1);
    //received phone number
    echo $phone = trim($cheapsms->number);
    echo "<br>";
     
    /* here use of the number in the registration form
    after which an SMS is sent to the phone
    */
     
    //wait * 10 in seconds
    $wt_wait = 7;
    //get code from SMS
    if(!$cheapsms->get_code($wt_wait))
    {
        echo("ERROR: $cheapsms->answer could not get code from SMS");
     
       //inform the service that we release the number
        $cheapsms->set_status(8);
    }
    else//if necessary, correct the parsing of the SMS text, if the code is not correctly parsed from it
    {
       //inform the service that everything is ok
        $cheapsms->set_status();
       //code from sms
        echo trim($cheapsms->code).'<br>';
    }
     
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

     

    C# example:

     

    Java Script example:

     
  • en/objects/cheapsms/functional/get_phone_number.txt · Last modified: 2020/10/14 11:24 (external edit)