In my code I use Curl to call dbupload.cgi which authenticates fine and returns a link to the dbmake.cgi url but when I tell Curl to use UNRESTRICTED_AUTH and FOLLOWLOCATION I keep getting a 401 Authorization Required. This seems like strange behavior because dbupload.cgi also requires authentication and works fine.
- Code: Select all
$url = 'http://mydomain.com/cgi-bin/ss/dbupload.cgi?clientApp=1&dbname=pages&filename=sample2.xml&uniqueName=File+Name';
$eld_user = 'my_shopsite_user';
$eld_pw = 'my_shopsite_pw';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); #input
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
curl_setopt($ch, CURLOPT_USERPWD, "{$eld_user}:{$eld_pw}");
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$info = curl_getinfo($ch);
$result = curl_exec($ch);
curl_close($ch);
var_dump($result);
Result:
Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
I also tried to just Curl the dbmake.cgi like that was generated by dbupload.cgi using authentication and got the same result.
Has anyone else had issues using dbmake.cgi from a script? Any help is much appreciated as I have been stuck on this for a while now.