PHP – CURL Authentication

MacBook avec code sur un bureau

To make a curl request with authentication, just add the CURLOPT_USERPWD option $ch curl_init(); curl_setopt ($ch,CURLOPT_URL, url'); curl_setopt ($ch, CURLOPT_USERPWD, "user:pswd"); curl_setopt ($ch,CURLOPT_CONNECTTIMEOUT.5); curl_setopt ($ch,CURLOPT_RETURNTRANSFER,1); $buffer – curl_exec ($ch); curl_close ($ch); if (empty($buffer)) print "Need to recover from this! <>"; } Else print "There was data returned using curl. <>"; print "Buffer content -$buffer." <>"; … Read more