我有一个 Web 服务,可以在我的浏览器中使用,但不能在 PHP 脚本中使用 CURL 调用。
这里我使用的代码与发送的登录名/密码示例一起使用。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD,'BmN+GP4VBev5tVzJU/altsyXXw0PXYcunbT8F8EatlbpctBXZp1OO2ySQyekZb5729qQPkdwdDBoUxMjBu1mlvv5Bt90GGRwyvEHGTMlT9cjs5YRpBJxEhksVyoL1Z4pwLAq3gKSj+PGW0HQhOSr8h7lyMG+9HJjL7pKeeds+Byn+TYnaium1MsGFg4TiE6Ztvr6rVpdaJSI3einSABuC1PCnNPkbHEdtwdrd8DU2jKcQ1fzderhmuJQE6pls6wwQjWF6sCTUTo/upUHUe0p5GY+7pKCHBXgNEhRhx3JgweiJN8ErxoiPCCIOdOScAEfcgZOgqQDGsJqnhuQ/5fKqg==:passwordOfTheUser');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
var_export(curl_getinfo($ch))."\n";
如果我查看 getInfo 的内容,我得到了这个
[...]
'request_header' => 'GET /uriNotRelevant.queryString=Data HTTP/1.1
Authorization: Digest username="BmN+GP4VBev5tVzJU/altsyXXw0PXYcunbT8F8EatlbpctBXZp1OO2ySQyekZb5729qQPkdwdDBoUxMjBu1mlvv5Bt90GGRwyvEHGTMlT9cjs5YRpBJxEhksVyoL1Z4pwLAq3gKSj+PGW0HQhOSr8h7lyMG+9HJjL7pKeeds+Byn+TYnaium1MsGFg4TiE6Ztvr6rVpdaJSI3einSABuC1PCnNPkbHEdtwdrd8DU2jKcQ1fzderhmuJQE6pls6w", realm="SVCCompagnonRelay Digest Authentication", nonce="MTM1NDQ4Nzc2NjkzNjoxYTRhMThkOTk5Yjc4OWY1Y2Q0MWQ3NzY3NzRlYzFlYw==", uri="/uriNotRelevant.queryString=Data", cnonce="MTczNDU1", nc=00000001, qop="auth", response="c319b14a40bf54955b764117d7f4bbc3"
Host: example.org
Accept: */*
Cookie: MBLPRDSession=C7B717115F119BAAB5C5BC308DD7FB18; WASMBLPRD2AND=mbltrap21and
',
)
您可以看到包含 login:password 的标头被截断。我尝试手动设置标题,但重现 DIGEST 协议更难
我不知道现在该怎么办:-(
您知道如何扩大摘要登录大小吗?
Edit²: 解决了问题,请参阅我的解决方案