PHP Curl Request with Username and Password Example
This article is focused on php curl request with username and password. if you want to see example of php curl basic auth username:$password then you are a right place. you can understand a concept of php curl authorization username:password. you can see php curl basic auth example. you will do the following things for php curl basic auth username password.
In this example, we will use CURLOPT_HTTPAUTH and CURLOPT_USERPWD to pass username and password for authorization. so let's see bellow simple example code here:
$username = 'username';
$password = 'password';
$URL = 'https://api.mywebtuts.com/api/users';
$ch = curl_init();
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
i hope it can help you...
We are Recommending you
- PHP Curl PUT Request Example Code
- PHP Curl Delete Request Example Code
- PHP Curl POST Request with Headers Example
- PHP Curl Get Request with Parameters Example
- PHP Curl Request with Certificate (cert pem file option) Example
- PHP Codeigniter Curl Post Request Example
- PHP curl post request with parameters and get json response
- Laravel CURL Request Example using ixudra/curl
- PHP Download File from URL using CURL Request Example
- How to Upload Image using jQuery Ajax in PHP?
- How to Find Day Name from Specific Date in PHP?
- How to Remove Null Values from Array in PHP?