asprsai Posted November 27, 2010 Share Posted November 27, 2010 hello guys., I need small help from. I am a java developer and am not well acquainted with php. I am developing a java application which calls a php web service (sugar CRM soap webservice)., so one of the web service method (login) takes a php struct as a parameter, user_auth which has three parameters username, password and version, all of them are strings. Can any one tell me what will be the output structured like when we print out the user_auth struct. I tried: 1) String user1 = "user_auth{username=will; password=18218139eec55d83cf82679934e5cd75; version=1.0;}"; 2) String user2 = "{'user_auth':{'username':'will','password':'18218139eec55d83cf82679934e5cd75', 'version':'1.0'}}"; Does any of the above strings match the output of a struct in php? If not what should it be like?? This would be of a great help for me if any one can tell me whats the right now. Thanks, aspr Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 27, 2010 Share Posted November 27, 2010 The second one comes close, just switch the single quotes and double quotes: <?php $user3 = '{"user_auth":{"username":"will","password":"18218139eec55d83cf82679934e5cd75","version":"1.0"}}'; ?> would be the json encoded form of an object or array. To see what it is in PHP, do either <?php print_r(json_decode($user3)); ?> which produces stdClass Object ( [user_auth] => stdClass Object ( [username] => will [password] => 18218139eec55d83cf82679934e5cd75 [version] => 1.0 ) ) or <?php print_r(json_decode($user3,true)); ?> which produces Array ( [user_auth] => Array ( [username] => will [password] => 18218139eec55d83cf82679934e5cd75 [version] => 1.0 ) ) Ken Quote Link to comment Share on other sites More sharing options...
asprsai Posted November 27, 2010 Author Share Posted November 27, 2010 Thanks for replying.. Actually those strings (user1 and user 2) are java strings., so i want to send a java string to a php web service., so that the php should be able to covert the java string and take it as a complex type(struct). So i will be passing the java string (user1 or 2 or 3) to the php web service and it should be able to recognize it as a struct. I tried the one you mentioned (user3) its not working., i might be doing something wrong. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.