Answer the question
In order to leave comments, you need to log in
How to run curl commands in PHP?
There are teams
Basic Authentication
$ curl -u "username" https://api.github.com
OAuth2 Token (sent in a header)
$ curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com
OAuth2 Token (sent as a parameter)
$ curl https://api.github.com/?access_token=OAUTH-TOKEN
Answer the question
In order to leave comments, you need to log in
There are built-in commands, do not fence bicycles.
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, 'https://api.github.com');
curl_setopt ($ch, CURLOPT_USERAGENT, 'cURL/php');
curl_setopt ($ch, CURLOPT_USERPWD, 'login:password');
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec ($ch);
Alternatively shell_exec('curl -u "username" https://api.github.com ') or exec('curl -u "username" https://api.github.com ')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question