douben1891 2014-05-14 04:57
浏览 33

POST和GET不起作用

I am practicing PHP and sending request on a server using REST Client add-on in Mozilla Firefox. I also tried different tool on chrome to check whether i am receiving data on server but unfortunately i am not receiving anything neither GET or POST. Only thing which i am able to receive is query string.

I didn't even write any code on server side just simple print commands.

<?php

var_dump($_REQUEST);
var_dump($_GET);
var_dump($_POST);
print_r($_GET);
print_r($_POST);

echo "working";


?>

This is INPUT

> This is test message.

And this is output.

array(0) {
}
array(0) {
}
array(0) {
}
Array
(
)
Array
(
)
working

Like is said only thing that works is query string. And this server i am using is free web service don't know if this helps.

This is android code that i am trying to receive.

byte[] jsonBytes = json.getBytes("UTF-8");

            URL url = new URL("http://androidapplicati.base.pk/");
            urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("POST");
             urlConnection.setDoOutput(true);
            urlConnection.setFixedLengthStreamingMode(jsonBytes.length);
             urlConnection
             .setRequestProperty("Content-Type", "application/json");
            urlConnection.setRequestProperty("Content-Length",
                    String.valueOf(jsonBytes.length));

             out = urlConnection.getOutputStream();
             out.write(jsonBytes);
             out.flush();
             urlConnection.getInputStream().read();
  • 写回答

2条回答 默认 最新

  • duanken7168 2014-05-14 05:07
    关注

    First of all please check did you pass any value using any method GET or POST. if yes than This is not your coding problem . This is your hosting server issue. my advice never use any free servers because there is not technical support and they are not secure..

    Your Code it working OK just change hosting server

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题