Jump to content

[已解决]请教关于webservice认证问题,谢谢


martinwang

Recommended Posts

我的运行结果是:
HTTP/1.0 401 Unauthorized Date: Tue, 25 Jan 2011 15:41:35 GMT Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 X-Powered-By: PrestaShop Webservice WWW-Authenticate: Basic realm="Welcome to PrestaShop Webservice, please enter the authentication key as the login. No password required." Execution-Time: 0 Content-Sha1: fe003ccbd70e1f0f9a84cf4904632460868f869f Content-Length: 220 Connection: close Content-Type: text/xml;charset=utf-8
以下是我的代码我已经在代码中输入了用户名和密码,但是不能得到xml页面,而在http://localhost/prestashop_1_4_0_9/api,输入用户名和密码(空),我却可以得到xml页面,有高手可以帮忙吗,谢谢,
$ch = curl_init();
$httpHeaders = array("Authorization: OAuth 2CL9O3GDMMBIF6PWLHZ7J13H0H28QMT5",
"X-PrettyPrint: true",
"Accept: application/json",
"User-Agent: PHP-RestApiClient/20.0",
"Expect:" );
$httpHeaders[] = "Content-Type: text/xml; charset=UTF-8";
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "2CL9O3GDMMBIF6PWLHZ7J13H0H28QMT5:");
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_URL, "http://localhost/prestashop_1_4_0_9/api");
$chResponse = curl_exec($ch);
curl_close($ch);
$exprResponse = explode("\n\r", $chResponse, 2);
print_r($chResponse);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...