CURL POST Request with Cookie Authorization CURL POST Request with Cookie Authorization curl curl

CURL POST Request with Cookie Authorization


The example above is using cookie authentication. Cookies are sent in the request headers. To use cookie authentication you need to somehow obtain the session ID and substitute that into the code. I am guessing you need to somehow open a session previously and then use that value in the cookie, however that does seem like an odd way to authenticate for an API. Also, I'm not sure if the leading underscore is a typo or not. You might want to try it without the underscore if it doesn't work:

"Cookie: SESSION_ID=cdf5b882667d24a2"

Or, if you want to use HTTP authentication, you need to provide a username and password doing something like

curl_setopt( $curl, CURLOPT_USERPWD, 'username:password' );

If all you have is a single value, it would probably go in the password part leaving the username blank:

curl_setopt( $curl, CURLOPT_USERPWD, ':WVdECUMScUZGGGBGOlhVODdGNXFkR253SA==' );