2015-09-11 43 views
1

我正在使用以下代码来查询手机的类型。我只使用php作为此项目的语言。我正在使用下面的代码。如何知道手机类型?

我只收到了电话“12252763867”为output.from下面的代码

$number->phone_number; 

的问题是如何获得手机的类型?

<?php 
require "NewServices/Twilio.php"; 
$AccountSid ="xxx" ; 
$AuthToken ="xxxx" ; 
$from = '<twilio phone>'; 
$to = '+12252763867'; 

$client1 = new Services_Twilio($AccountSid, $AuthToken); 
$client = new Lookups_Services_Twilio($AccountSid, $AuthToken); 


$number = $client->phone_numbers->get("+12252763867"); 
$body = $number->phone_number; 

try 
{ 
    $client1->account->sms_messages->create($from,$to,$body); 
} catch (Services_Twilio_RestException $e) { 

} 

?> 
+0

你是指什么类型的手机?你指的是哪个国家?什么规则适用?例如在英国,以07开头的号码就是手机。在我们能够帮助您之前,您必须编辑您的问题以包含更多信息。 –

+0

我想从GET表达式的响应中检索类型信息的国家代码等。类型应告诉我手机是手机,固定电话还是传真机。这个国家是美国 –

回答

1

Twilio开发者传道这里。

一旦你的电话号码,抬头一看,你这里显示:

$number = $client->phone_numbers->get("+12252763867"); 
$body = $number->phone_number; 

可以查询对其他一些领域也一样:

$country = $number->country_code 
$format = $number->national_format 

如果您想了解更多信息,您可以通过Type参数作为“载体”:

$number = $client->phone_numbers->get("+12252763867", array("Type" => "carrier")) 

然后,您可以得到你所问的数字的类型。

$type = $number->carrier->type 

抬头显示每个电话号码的运营商信息成本0.005美元。