钛上的TiHttpClient甚至不发送

时间:2015-05-04 08:17:05

标签: android titanium titanium-mobile titanium-android

尝试与我的API进行互动,但该应用甚至无法发送请求:

var connectToAppbis = {
   login: function(login, password) {
         var params = {
                    "login": login,
                    "password": password
                };
         var url = "http://api.city1.fr/idstock/dev/v3/index.php/auth";
         var client = Ti.Network.createHTTPClient({
             // function called when the response data is available
             onload : function(e) {
                 Titanium.API.info(this.responseText);
                 var json = JSON.parse(this.responseText);
             },
             // function called when an error occurs, including a timeout
             onerror : function(e) {
                 Ti.API.debug(e.error);
                 alert('error');
             },
             timeout : 5000  // in milliseconds
         });
         // Prepare the connection.
         client.setRequestHeader("Content-Type", "application/json; charset=utf-8");
         client.open("POST", url);
         // Send the request.
         client.send(JSON.stringify(params));
    }
};

我在清单上添加了权限,我尝试了JSON.stringify()并且没有问题,这里有什么问题?我应该包括什么吗? 因为在http://api.city1.fr/idstock/dev/v3/index.php/auth

我按预期获得了JSON值...

错误日志:

[ERROR] :  TiHttpClient: (TiHttpClient-1) [15666,15666] HTTP Error (org.apache.http.client.HttpResponseException): Not Found
[ERROR] :  TiHttpClient: org.apache.http.client.HttpResponseException: Not Found
[ERROR] :  TiHttpClient:    at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:275)
[ERROR] :  TiHttpClient:    at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:219)
[ERROR] :  TiHttpClient:    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:974)
[ERROR] :  TiHttpClient:    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:954)
[ERROR] :  TiHttpClient:    at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1334)
[ERROR] :  TiHttpClient:    at java.lang.Thread.run(Thread.java:864)

0 个答案:

没有答案