TWILIOのカールクエリーは、国コードと電話番号以外に何かアイデアを返してくれないようですか?twilio php curl not carrierを返す
キャリアは私のテストページから細かい 結果ましたスルー来るtwilio私は上のルックアップ:
no curl error
stdClass Object
(
[caller_name] =>
[country_code] => US
[phone_number] => +1201832xxxx
[national_format] => (201) 832-xxxx
[carrier] =>
[add_ons] =>
[url] => https://lookups.twilio.com/v1/PhoneNumbers/+1201832xxxx
)
caller_name is
caller_name is
caller_type is
error_code is
country_code is US
phone number is +1201832xxxx
national_format (201) 832-xxxx
Carrier name is
Carrier name is
Carrier type is
error_code is
mobile_network_code
mobile_country_code is
no curl error
コードが
$cSession = curl_init("https://lookups.twilio.com/v1/PhoneNumbers/+1201832xxxx");
curl_setopt($cSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cSession, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cSession, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($cSession, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($cSession, CURLOPT_POSTFIELDS, "Type=carrier");
curl_setopt($cSession, CURLOPT_USERPWD, "xxxxxxx:xxxxxxx");
$response = curl_exec($cSession);
$err = curl_error($cSession);
if ($err) {
echo "cURL Error #:" . $err."<br/>";
} else {
echo "no curl error<br/>";
}
$response = json_decode($response);
echo "<pre>"; print_r($response); echo "</pre><br/>";
echo "caller_name is ".$response->caller_name."<br/>";
echo "caller_name is ".$response->caller_name->caller_name."<br/>";
echo "caller_type is ".$response->caller_name->caller_type."<br/>";
echo "error_code is ".$response->caller_name->error_code."<br/>";
echo "country_code is ".$response->country_code."<br/>";
echo "phone number is ".$response->phone_number."<br/>";
echo "national_format ".$response->national_format."<br/>";
echo "Carrier name is ".$response->carrier."<br/>";
echo "Carrier name is ".$response->carrier->name."<br/>";
echo "Carrier type is ".$response->carrier->type."<br/>";
echo "error_code is ".$response->carrier->error_code."<br/>";
echo "mobile_network_code ".$response->carrier->mobile_network_code."<br/>";
echo "mobile_country_code is ".$response->carrier->mobile_country_code."<br/>";
'if($ err)'が有効なテストではない。あなたが擦っているサイトが空の文字列または '0'文字を返すと、それもfalseとカウントされ、false-positiveを引き起こします。 boolean false、 'if($ err === false)'を明示的にテストする必要があります。ウェブサイトがphp boolean falseを返すことはできません。 TEXTのみを返すことができます。 –