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 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热
  • ¥15 this signal is connected to multiple drivers怎么解决
  • ¥60 请查询全国几个煤炭大省近十年的煤炭铁路及公路的货物周转量
  • ¥15 请帮我看看我这道c语言题到底漏了哪种情况吧!
  • ¥66 如何制作支付宝扫码跳转到发红包界面
  • ¥15 pnpm 下载element-plus