在GWT和PHP之间传递数据

I'm a newbie with GWT and PHP, and after reading some tutorials it's not clear for me how to efficiently exchange data between the GWT frontend and PHP backend. I successfully followed the Google tutorials where is suggested to use the RequestBuilder class to get data from PHP. But when I need to save the work done in GWT, how to efficiently pass the data to PHP? It's not clear for me how to use the RequestBuilder for this task. The solution that I found for now is

RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));
    builder.setHeader("Content-Type", "application/json");
        try {
              Request request = builder.sendRequest("{\"done\":false,\"description\":\"Some text\",\"priority\":0}", new RequestCallback() {...

and in PHP side

$arr = json_decode(file_get_contents("php://input"),true);
$done = (int)$arr['done'];
$description = $arr['description'];
$priority = $arr['priority'];
mysql_query("INSERT INTO Tasks (done, description, priority)
    VALUES ($done, '$description', $priority)");

Is this the best approach? Have someone found a working example in the web? Every opinion is welcome...

I think, working with JSON when interacting with non-Java servers is fine. You can build the JSON strings on the client side in a safer way by using the JSON module:

In your .gwt.xml file add

<inherits name='com.google.gwt.json.JSON'/>

Then you can construct your example string like

final JSONObject jsonObject = new JSONObject();

jsonObject.put("done", JSONBoolean.getInstance(false));
jsonObject.put("description", new JSONString("Some text"));
jsonObject.put("priority", new JSONNumber(0));

final String jsonString = jsonObject.toString();