Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xmlhttprequest在phonegap/android应用程序上返回401_Android_Xml_Cordova_Xmlhttprequest - Fatal编程技术网

Xmlhttprequest在phonegap/android应用程序上返回401

Xmlhttprequest在phonegap/android应用程序上返回401,android,xml,cordova,xmlhttprequest,Android,Xml,Cordova,Xmlhttprequest,我想通过带有xmlhttprequest的PhoneGap/android应用程序访问服务web,但下面的代码返回“Status is 401” 有人能帮我解释错误或提供解决方案吗?如果您的网站是由prestashop创建的,因此要使用Xmlhttprequest访问Web服务,request.open应该如下所示: request.open("GET","http://www.mysite.fr/api/customes/2?PHP_AUTH_USER="+PHP_AUTH_USER+"&am

我想通过带有xmlhttprequest的PhoneGap/android应用程序访问服务web,但下面的代码返回“Status is 401”


有人能帮我解释错误或提供解决方案吗?

如果您的网站是由prestashop创建的,因此要使用Xmlhttprequest访问Web服务,request.open应该如下所示:

request.open("GET","http://www.mysite.fr/api/customes/2?PHP_AUTH_USER="+PHP_AUTH_USER+"&ws_key="+ws_key,true);

使用:
PHP\u AUTH\u USER=“”和ws\u ke=key\u由web服务生成,401井是未经授权的错误。该网站是否需要您登录?不,该网站不需要登录,但web服务需要密钥
request.open("GET","http://www.mysite.fr/api/customes/2?PHP_AUTH_USER="+PHP_AUTH_USER+"&ws_key="+ws_key,true);