2

I am using Retrofit Lib.

My code is

public class TestPostData {
  final String username;
  final String password;

  TestPostData(String username, String password) {
    this.username = username;
    this.password = password;
  }
}

and interface is

    interface Test {
      @POST("/post.php")
      void testMethod(@Body TestPostData postbody,@Query("qName") String qName,Callback<Response> callback);
  }

Rest Adapter

RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint(TEST_URL)
    .setLogLevel(RestAdapter.LogLevel.FULL)
    .build();

and call it as

testObj.testMethod(new TestPostData("myusername", "mypassword"),"myname",new Callback<Response>() { ..............

at the server side i get $_POST array as empty. How to get username and password value at server side. I get the name value.

Joginder Sharma
  • 73
  • 4
  • 11

1 Answers1

5

I know this is a little bit late, but to read the request body in PHP you can do:

<?php
   echo file_get_contents('php://input');
?>

More about this here.

Community
  • 1
  • 1
VM4
  • 6,321
  • 5
  • 37
  • 51