当我通过 Phonegap 加载 Web 应用程序并发出 Web 请求(通过 AJAX 或其他方式)时,根本不会设置 REFERRER HTTP 标头。这会干扰某些第三方网站的功能。如何发送 REFERRER 标头?
(我使用的是Phonegap 3.5.0-0.20.10)
正如@JamesWong 所说,现在有一个名为科尔多瓦HTTP https://github.com/wymsee/cordova-HTTP适用于所有平台。
您可以使用添加该插件cordova plugin add https://github.com/wymsee/cordova-HTTP.git
命令,然后您可以添加任何 http 标头,如下所示。
cordovaHTTP.post("https://google.com/, {
id: 12,
message: "test"
}, { Authorization: "OAuth2: token" }, function(response) {
// prints 200
console.log(response.status);
try {
response.data = JSON.parse(response.data);
// prints test
console.log(response.data.message);
} catch(e) {
console.error("JSON parsing error");
}
}, function(response) {
// prints 403
console.log(response.status);
//prints Permission denied
console.log(response.error);
});
Source: https://github.com/wymsee/cordova-HTTP https://github.com/wymsee/cordova-HTTP
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)