Issue
I want to get the verification code when I made a request for the registration of a new number on twilio. The call gets made and ask for the verification number but I can't see the verification number.
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
use Twilio\Rest\Client;
// Find your Account Sid and Auth Token at twilio.com/console
$sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token = "your_auth_token";
$twilio = new Client($sid, $token);
$validation_request = $twilio->validationRequests
->create("+14158675310", // phoneNumber
array(
"friendlyName" => "My Home Phone Number"
)
);
print($validation_request->friendlyName);
This is the code given on the documentation which was supposed to return the below result array. but I only get the friendly name even after trying to print entire array.
{
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"call_sid": "CAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"friendly_name": "My Home Phone Number",
"phone_number": "+14158675310",
"validation_code": 100
}
Note :- I used my original values for each variable and also tried to print entire array of $validation_request but it was of no use.
May be I am missing something minor. Any help is accepted. Thanks in advance.
Solution
Twilio developer evangelist here.
The code snippet you shared ends with
print($validation_request->friendlyName);
Which should just show the friendly name you created the number validation request with. If you want the validation code you should look at:
print($validation_request->validationCode);
Let me know if that helps.
Answered By - philnash Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.