User Tools

Site Tools


Sidebar

en:objects:cheapsms:functional:set_status

set_status

set_status($status=6); - report the activation status.

the input Function accepts parameters:

  • $status – activation statuses:
    -1 - cancel activation
    1 - notify the number is ready (SMS sent to the number)
    3 - request another code (free of charge)
    6 - complete activation(if the status was "code received" - marks successful and completes
    8 - notify that the number is used and cancel activation [This status is canceled, valid unless you received an SMS to the number]

    After testing, the function returns the result of its work to the script :
  • true – the number is ready
  • false – the number is not ready

    You can view the service's response in the cheapsms->answervariable.

    The cheapsms->answer variable can be:

      ACCESS_READY - number readiness confirmed
      ACCESS_RETRY_GET - waiting for a new SMS
      ACCESS_ACTIVATION - service successfully activated
      ACCESS_CANCEL - the activation is canceled.

      Possible error:
      NO_ACTIVATION - activation id does not exist
      BAD_SERVICE - invalid service name
      BAD_STATUS - invalid status
      BAD_KEY - invalid API key
      BAD_ACTION - invalid action
      ERROR_SQL - SQL server error


    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/set_status.txt · Last modified: 2020/10/14 11:25 (external edit)