duanchao1002
2012-02-06 15:10
浏览 31

单独的HTTP连接结果(PHP回声)

In my Android application I make a HTTP POST connection:

serverresponse = CustomHttpClient.executeHttpPost(url, postParameters);

All working fine. The url is pointing to a php page on my server. It echos an array of image urls in JSON format like this:

[".\/pictures\/q\/thumbnails\/28052011172.jpg",".\/pictures\/q\/thumbnails\/picca1.jpg",".\/pictures\/q\/thumbnails\/lockscreen_006.jpg"]

What I want to do is also echo the size of directory. That works fine too, but that puts it right after the JSON array, like so:

echo (json_encode($files));
echo (filesize_r($path));

[".\/pictures\/q\/thumbnails\/28052011172.jpg",".\/pictures\/q\/thumbnails\/picca1.jpg",".\/pictures\/q\/thumbnails\/lockscreen_006.jpg"]4223566

4223566 is the number of bytes. In my application I want to split these two values into different strings so I can use them.

In short, I want to separate these two php echos. I don't want to make two separate HTTP connections for both of them.

Sorry if my question isn't clear enough, I sometimes have a hard time explaining stuff in English.

图片转代码服务由CSDN问答提供 功能建议

在我的Android应用程序中,我建立了一个HTTP POST连接:

  serverresponse = CustomHttpClient.executeHttpPost(url,postParameters); 
   
 
 

一切正常。 url 指向我服务器上的php页面。 它回显了一个JSON格式的图像网址数组,如下所示:

[“。\ / pictures \ / q \ / thumbnails \ /28052011172.jpg”,“。\ / pictures \ / q \ / thumbnails \ /picca1.jpg“,”。\ / pictures \ / q \ / thumbnails \ /lockscreen_006.jpg“]

我想要什么 要做的还是回显目录的大小。 这也很好,但是它就在JSON数组之后,就像这样:

  echo(json_encode($ files)); 
echo(filesize_r($ path))  ; “\ /图片\ / q \ /缩略图\ /28052011172.jpg”。
   
 
 

<代码> [,“\ /图片\ / q \ / 缩略图\ /picca1.jpg“,”。\ / pictures \ / q \ / thumbnails \ /lockscreen_006.jpg“] 4223566

4223566是字节数。 在我的应用程序中,我想将这两个值拆分为不同的字符串,以便我可以使用它们。

简而言之,我想分开这两个php回声。 我不想为它们两个单独的HTTP连接。

对不起,如果我的问题不够清楚,我有时很难用英语解释一些东西。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duandao1931 2012-02-06 15:17
    已采纳

    Could you not just make one json object which contains the two values your require?

    e.g.

    $response = array(
        'pictures'=>$files,
        'filesize'=> filesize_r($path)
    );
    echo json_encode($response);
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • doupian9490 2012-02-06 15:17

    Use params in you php so you can select wich action to do

    评论
    解决 无用
    打赏 举报
  • dongqichang7988 2012-02-06 15:18

    not sure if I understand your question fully, but:

    $json['files'] = $files;
    $json['size'] = filesize_r($path);
    
    echo json_encode($json);
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题