PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 19, 2022

[FIXED] How to transfer Twilio lookup cURL code to PHP cURL

 November 19, 2022     curl, php, twilio, twilio-php     No comments   

Issue

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 AccountSid and AuthToken.

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

How to do that? Thanks!


Solution

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);


Answered By - hlscalon
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing