duanqujing3863 2012-05-21 13:12
浏览 44
已采纳

GWT + PHP,管理JSON

I'm trying to connect GWT with a PHP back-end; I successfully loaded some data in the front-end using the provided tutorial: https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideHttpRequests ; now I'm trying to send data from GWT to PHP using the same piece of code provided, but I don't know how I can modify it. In the Java GWT class I've done

RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
    builder.setHeader("Content-Type", "application/json");
    try {
          Request request = builder.sendRequest("{\"data\":\"hello\"}", new RequestCallback() { ...

And then in the php script

echo json_decode($_POST);

But the error is "[INFO] [testapp] - Warning: json_decode() expects parameter 1 to be string, array given in C:\xampp\htdocs\TestApp\TestApp.php on line 25"

Can anyone provide a working example of this situation? Or link me some tutorial or document that talk more about how to use GWT with PHP? There is not so much in the official site...

  • 写回答

3条回答 默认 最新

  • doumao6212 2012-05-21 13:29
    关注
    echo json_decode($HTTP_ROW_POST_DATA);
    

    or

    echo json_decode(file_get_contents("php://input"))
    

    See http://php.net/manual/en/reserved.variables.httprawpostdata.php and http://php.net/manual/en/wrappers.php.php (the latter should be preferred)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办