This seems simple, but I am stuck.
I am trying to use basic authentication using an API. I can use curl from the command line, but I can't figure out how to convert this to PHP and cookies.
Please help!
This seems simple, but I am stuck.
I am trying to use basic authentication using an API. I can use curl from the command line, but I can't figure out how to convert this to PHP and cookies.
Please help!
You will use the setcookie function, as shown in this tutorial.
http://www.learnphp-tutorial.com/Sessions.cfm
I don't see what cURL would have to do with cookies and authentication.
Basic authentication and cookies are completely different things. If I understand correctly, you're trying to make a curl request using PHP. If you want basic authentication, do this:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
If you want a cookie:
curl_setopt($ch, CURLOPT_COOKIE, "name=value");