Php 钛与REST API
我试图调用用PHP开发的RESTAPI。我的钛代码非常简单Php 钛与REST API,php,rest,titanium,titanium-mobile,Php,Rest,Titanium,Titanium Mobile,我试图调用用PHP开发的RESTAPI。我的钛代码非常简单 var url = "http://www.sample.com"; var client = Ti.Network.createHTTPClient( { // function called when the response data is available onload : function(e) { Ti.API.info("Recei
var url = "http://www.sample.com";
var client = Ti.Network.createHTTPClient(
{
// function called when the response data is available
onload : function(e)
{
Ti.API.info("Received text: " + this.responseText);
alert('success');
}
});
// Prepare the connection.
client.open('GET', url,true);
// Send the request.
client.send();
我得到的错误如下
[INFO] : Received text: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[ERROR] : was encountered while trying to use an ErrorDocument to handle the request.</p>
[INFO] : <html><head>
[INFO] : <title>403 Forbidden</title>
[INFO] : </head><body>
[INFO] : <h1>Forbidden</h1>
[INFO] : <p>You don't have permission to access /
[INFO] : on this server.</p>
[INFO] : <p>Additionally, a 404 Not Found
[ERROR] : <hr>
[ERROR] : <address>Apache Server at www.sample.com Port 80</address>
[ERROR] : </body></html>
[INFO]:收到的文本:
[错误]:尝试使用ErrorDocument处理请求时遇到
[资讯]:
[信息]:403禁止
[资讯]:
[信息]:禁止
[信息]:您没有访问权限/
[信息]:在此服务器上
[信息]:此外,找不到404
[错误]:
[错误]:位于www.sample.com端口80的Apache服务器
[错误]:
我认为这与参数Access Control Allow Origin有关,我将该参数更改为*,但没有用。
在更改ACAO参数后,我能够从普通HTML+JS代码中调用API。
请帮忙。
感谢并问候阿披谢克您是否100%确定您拨打的url是正确的?是的,因为它似乎在浏览器上工作。