2
Twillioは、電話番号を検索するときにプライベートプロパティが割り当てられたオブジェクトを返します。右下の私は、これは私がtwillio電話番号検索sdk5x
object(Twilio\Rest\Lookups\V1\PhoneNumberInstance)#23 (4) {
["properties":protected]=>
array(6) {
["callerName"]=>
NULL
["countryCode"]=>
string(2) "LK"
["phoneNumber"]=>
string(12) "+94xxxxxxxx"
["nationalFormat"]=>
string(12) "xxxxxxxxxx"
["carrier"]=>
NULL
["addOns"]=>
NULL
}
["solution":protected]=>
array(1) {
["phoneNumber"]=>
string(11) "94xxxxxxxxx"
}
}
を取得していた結果の断片である
function isValidNumber($number) {
try{
$obj = $this->client->lookups->phoneNumbers($number)->fetch();
return $obj;
}catch(Twilio\Exceptions\RestException $e){
return false;
}
}
を使用するコードは、にphoneNumberキーを取得するためのエレガントな方法はありますか?また、tryキャッチは、無効なエントリが入るとすぐに、どちらも助けてくれないように見えますが、例外はどこにでもあります。私はSDK 5xを使用しています
何らかの理由であなたがcURLなしで除外されている場合は、これが実際に動作します。 –