【发布时间】:2014-07-17 11:35:16
【问题描述】:
当我包含 function.php 文件时,Android 无法获取数据。但是当我删除当前 php 文件中的文件包含代码时,Android 会获取数据。如何解决此错误。我想在 function.php 文件中使用一些函数。所以我必须使用包含代码调用function.php。
不知道是android还是php的问题?
我的 PHP 版本:5.3.10 阿帕奇版本:2.2.21
我的安卓代码:
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")));
}
谁能帮忙?????????
【问题讨论】:
-
它不在 android 端..请检查你的 php 代码
-
@NightCrawler...好的,谢谢。我检查了很多次,但我得到的数据不包括function.php。但使用时无法获取数据。那怎么办,请....
-
对不起@thet 我不是一个 php 人.. 你的 android 代码对我来说似乎很好,这就是为什么我告诉你这是一个 php 问题..
-
@NightCrawler 感谢您的回复(评论)
标签: php android web-services api httpresponse