Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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
无法从使用php和android的webservice上的服务器加载数据_Php_Android_Web Services_Api_Httpresponse - Fatal编程技术网

无法从使用php和android的webservice上的服务器加载数据

无法从使用php和android的webservice上的服务器加载数据,php,android,web-services,api,httpresponse,Php,Android,Web Services,Api,Httpresponse,当我包含function.php文件时,Android无法获取数据。但当我删除当前php文件中的文件include代码时,Android获取数据。如何解决此错误。我想在function.php文件中使用一些函数。因此,我必须使用include代码调用function.php 我不知道,是android还是php的错 我的PHP版本:5.3.10 apache版本:2.2.21 我的android代码: HttpClient client = new DefaultHttpClient();

当我包含function.php文件时,Android无法获取数据。但当我删除当前php文件中的文件include代码时,Android获取数据。如何解决此错误。我想在function.php文件中使用一些函数。因此,我必须使用include代码调用function.php

我不知道,是android还是php的错

我的PHP版本:5.3.10 apache版本:2.2.21

我的android代码:

 HttpClient client = new DefaultHttpClient();
        HttpConnectionParams.setConnectionTimeout(client.getParams(), 500000);
        HttpConnectionParams.setSoTimeout(client.getParams(), 500000);
        HttpUriRequest request = new HttpGet(CategoryAPI);
        HttpResponse response = client.execute(request);
        InputStream atomInputStream = response.getEntity().getContent();
        BufferedReader in = new BufferedReader(new InputStreamReader(atomInputStream));

        String line;
        String str = "";
        while ((line = in.readLine()) != null){
            str += line;
        }

        // parse json data and store into arraylist variables
        JSONObject json = new JSONObject(str);
        JSONArray data = json.getJSONArray("data");

        for (int i = 0; i < data.length(); i++) {
            JSONObject object = data.getJSONObject(i); 

            JSONObject feed = object.getJSONObject("Feeds"); 

            FeedItem.allFeedItemsList.add(new FeedItem(Integer.parseInt(feed.getString("id")), feed.getString("name"), feed.getString("post_img"), feed.getString("post_description"), feed.getString("userimage"), feed.getString("post_date"), feed.getString("post_title")));   
        }
HttpClient=newdefaulthttpclient();
HttpConnectionParams.setConnectionTimeout(client.getParams(),500000);
HttpConnectionParams.setSoTimeout(client.getParams(),500000);
HttpUriRequest请求=新的HttpGet(CategoryAPI);
HttpResponse response=client.execute(请求);
InputStream atomInputStream=response.getEntity().getContent();
BufferedReader in=新的BufferedReader(新的InputStreamReader(atomInputStream));
弦线;
字符串str=“”;
而((line=in.readLine())!=null){
str+=直线;
}
//解析json数据并存储到arraylist变量中
JSONObject json=新的JSONObject(str);
JSONArray data=json.getJSONArray(“数据”);
对于(int i=0;i

任何人都可以帮助?????

现在我可以用ANSI编码来解决我的错误。由于我使用UTF-8编码,android无法加载。现在,一切都好了。谢谢……

尝试使用此库:-。
您也可以使用此加载实时数据。

它不在android端。请检查您的phpcode@NightCrawler...ok谢谢我检查了很多次,但是我得到的数据没有包括function.php。但使用时无法获取数据。那么如何做,请…对不起@thet我不是一个php的家伙。。您的android代码对我来说似乎很好,这就是为什么我告诉您这是一个php问题。@NightCrawler感谢您的回复(评论)