Ivijan Stefan Stipić Ivijan Stefan Stipić - 7 months ago 49
PHP Question

How to transfer Twilio lookup cURL code to PHP cURL

I have this curl code:

curl -X GET https://lookups.twilio.com/v1/PhoneNumbers/(919) 410-7522\
-d "Type=carrier"
-u "{AccountSid}:{AuthToken}"

I try to convert in PHP cURL but I stack on how to send

I need this code only to check if number is valid and mobile or landline.

How to do that? Thanks!


Just use CURLOPT_USERPWD option

$ch = curl_init("https://lookups.twilio.com/v1/PhoneNumbers/(919)%20410-7522");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_POSTFIELDS, "Type=carrier");
curl_setopt($ch, CURLOPT_USERPWD, "{AccountSid}:{AuthToken}");
$response = curl_exec($ch);