get_code

get_code($wt_wait); - get activation code from SMS.

The function accepts parameters as input:

  • $wt_wait – wait *10 seconds.
    After testing, the function returns the result of its work to the script :
  • true – the operation was performed successfully
  • false – the operation was not completed

    The resulting code itself can be obtained from the simnet->codevariable. However, if your text message is not parsed correctly, use the simnet->answervariable for parsing.

    The simnet->answer variable can be:

    PHP example: simnet->".basename(__FILE__)."
    "; //set the service api key $simnet->api_key = '3161df9b1fe1ccb8cfd7dA91db765de8'; //get phone number if(!$simnet->get_phone_number('ot')) { while($simnet->answer == "NO_NUMBERS") { $simnet->get_phone_number('ot'); sleep(10); } if(strpos($simnet->answer, 'ACCESS_NUMBER') === false) { echo("answer $simnet->servis of the $simnet->answer
    "); $app->quit(); } } //sms sent $simnet->set_status(1); //received phone number echo $phone = trim($simnet->number); echo "
    "; /* use the number here 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(!$simnet->get_code($wt_wait)) { echo("ERROR: $simnet->answer could not get code from SMS"); //inform the service that we release the number $simnet->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 $simnet->set_status(); //code from sms echo trim($simnet->code).'
    '; } //end echo "

    "; //Quit $app->quit(); ?>
    Python example: C# example: Java Script example: