Twilio create address subaccount issue api php
I have a little problem with my code! I'm trying to create an address for a subaccount in twilio (in order to buy some number where an address are required).
My code:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
// Get the PHP helper library from twilio.com/docs/php/install
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
use TwilioRestClient;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "xxxxx";
$token = "xxxx";
$client = new Client($sid, $token);
$address = $client->addresses->create(
array(
"CustomerName" => "Customer",
"Street" => "2 rue du chapelier ",
"City" => "",
"Region" => "France",
"PostalCode" => "75020",
"IsoCountry" => "FR",
)
);
?>
And I have in return this error
Warning: Missing argument 2 for TwilioRestApiV2010AccountAddressList::create(), called in /Applications/MAMP/htdocs/taddresses.php on line 26 and defined in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 49
Warning: Missing argument 3 for TwilioRestApiV2010AccountAddressList::create(), called in /Applications/MAMP/htdocs/taddresses.php on line 26 and defined in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 49
Warning: Missing argument 4 for TwilioRestApiV2010AccountAddressList::create(), called in /Applications/MAMP/htdocs/taddresses.php on line 26 and defined in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 49
Warning: Missing argument 5 for TwilioRestApiV2010AccountAddressList::create(), called in /Applications/MAMP/htdocs/taddresses.php on line 26 and defined in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 49
Warning: Missing argument 6 for TwilioRestApiV2010AccountAddressList::create(), called in /Applications/MAMP/htdocs/taddresses.php on line 26 and defined in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 49
Notice: Undefined variable: street in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 54
Notice: Undefined variable: city in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 55
Notice: Undefined variable: region in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 56
Notice: Undefined variable: postalCode in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 57
Notice: Undefined variable: isoCountry in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php on line 58
Fatal error: Uncaught exception 'TwilioExceptionsRestException' with message '[HTTP 400] Unable to create record: IsoCountry must be provided' in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Version.php:85 Stack trace: #0 /Applications/MAMP/htdocs/twilio-php-master/Twilio/Version.php(207): TwilioVersion->exception(Object(TwilioHttpResponse), 'Unable to creat...') #1 /Applications/MAMP/htdocs/twilio-php-master/Twilio/Rest/Api/V2010/Account/AddressList.php(68): TwilioVersion->create('POST', '/Accounts/AC545...', Array, Array) #2 /Applications/MAMP/htdocs/taddresses.php(26): TwilioRestApiV2010AccountAddressList->create(Array) #3 {main} thrown in /Applications/MAMP/htdocs/twilio-php-master/Twilio/Version.php on line 85
I use the twilio php api. Im able to create subaccount, search new number, buy number etc etc but for addresses im stuck!
Twilio developer evangelist here.
I'm not sure whether you're using version 4 or version 5 of the Twilio PHP helper library but either way you're providing the arguments incorrectly. You shouldn't be providing an array of arguments, instead they should be provided as positional arguments. See the version 4 and version 5 source code.
So your code should look like:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
// Get the PHP helper library from twilio.com/docs/php/install
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
use TwilioRestClient;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "xxxxx";
$token = "xxxx";
$client = new Client($sid, $token);
$address = $client->addresses->create(
"Customer", "2 rue du chapelier ", "", "France", "75020", "FR"
)
);
?>
Let me know if that helps.
链接地址: http://www.djcxy.com/p/58126.html