0

Using following method i can login to API:

$ curl -v "http://www.test.com/a/b/c?id=1234" -u user1 -LK -XGET; 

But, In PHP how can i submit username/password which is asked by htpasswd popup?

public static function sendSMS($from, $to, $username, $password, $text) { $text = rawurlencode($text); $uri = "https://www.voipbuster.com/myaccount/sendsms.php?username={$username}&password={$password}&from={$from}&to={$to}&text={$text}"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); //curl_setopt($ch, CURLOPT_TIMEOUT, '3'); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($ch, CURLOPT_POST, false); // //curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); $result = curl_exec($ch); curl_close($ch); } 
1

1 Answer 1

0

You can use the following options:

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); 
Sign up to request clarification or add additional context in comments.

Comments