我在我的项目中实现了twilio,我必须使用lookups api来确定给定的手机号码是否是“mobile”类型,但是当我使用v2->lookups时,它一直显示异常Unknown Version v2 这是我的代码:
$account_sid = config('Xyzshj676********'); $auth_token = config('12HjYjbksjJHJ*******'); $client = new Client($account_sid, $auth_token); $phone_number_lookup2 = $client->lookups->v2->phoneNumbers("+14159929960")->fetch(["fields" =>"line_type_intelligence"]);
我尝试使用 v1 查找,但它显示来自 twilio api 的空响应
只需使用curl代替client,如下所示:
$base_url = "https://lookups.twilio.com/v2/PhoneNumbers/+1XXXXXXXXXX?Fields=line_type_intelligence";
$crl = curl_init($base_url);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($crl, CURLOPT_USERPWD, "$account_sid:$auth_token");
$response = curl_exec($crl);
curl_close($crl);
$responseArray = (array)json_decode($response,true);
info($responseArray);