Sending Array From Android To Server Side via Post Request -
good day.im sending post request php server side this
httpclient client = new defaulthttpclient(); httppost post = new httppost("my server name"); multipartentity reqentity = new multipartentity( httpmultipartmode.browser_compatible); /*stringtokenizer tokens = new stringtokenizer(from.gettext().tostring(), "-"); string shortstring = tokens.nexttoken(); string longstring = tokens.nexttoken(); stringtokenizer tokens2 = new stringtokenizer(to.gettext().tostring(), "-"); string shortstringto = tokens2.nexttoken(); string longstringto = tokens2.nexttoken();*/ try { reqentity.addpart("type", new stringbody("3"));
server side receives this
array ( [type] => 3 )
all seems afar wants me send him array.i send this
arraylist<string> array = new arraylist(); aray.add("hello"); reqentity.addpart("array", new stringbody(array.tostring()));
he receives this
array ( [type] => 1 [array]=> [hello]; )
all seems assumes thats i'm sending wrong , wants array send can receive way.
array ( [type] => 1 [array]=> array( [header name of array]=>"value of array" ) )
i google every bit read every single line of every site,and did not found close wants if send array wrote,otherwise wants array of inside array key name of inner array , value of inner array,which don't know somehow not possible opinion in way wants.so possible?can send array way wants in last written code?
sorry don't have enough points post comment. need provide little more information server using.
if using php, pretty simple, once have set secure connection need send response in following manner:
$response["success"] = 0; $response["message"] = "some message"; die(json_encode($response));
Comments
Post a Comment