Reputation: 1610
I know how obtain info from a webservice: connecting (sending url, user and pass) and calling a method passing parameters to it using nusoap. Here's and example:
$client = new nusoap_client($webServiceURL, 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword);
$session_header = "<UserCredentials xmlns='http://page.net/Webservice/'><Userid>".$username."</Userid><Password>".$password."</Password></UserCredentials>";
$client->setHeaders($session_header);
$params = array('param_a'=> $var_a, 'param_b'=> $var_b);
$result = $client->call('nameOfMethod', $params);
But what I don't know is how to send info via url given this:
I have a registration form, and once it is submited I have to send:
Request: [base_path]/register/[name]/[address]/[email]/[phone]
Response:
OK (is registered): header content: 200; body content xml:
Fields: [pass]
KO (is not registered): header content: 401; body content XML:
<response>
<error>
[error number]
</error>
</response>
Fields: [error number]
Knowing this, please follow me through it, what do I have to do after the form is submitted? As you see, I'm quite new to it and I'm totally lost. Thanks a lot
Upvotes: 0
Views: 4914
Reputation: 76
I was trying using SOAP, and I was wrong (sorry I'm learning). What I am doing here is creating a REST request.
I've done so far:
$request = "http://path.com/app/register/".$phone."/".$gender."/".$address."/". $name;
$response = file_get_contents($request);
But when I print the response I get: 1d1ffaf569a8a6b3ddc5e88c1c219c22
When I should be getting a 200 in the headers and an xml in the body if the response is OK.
When the response is KO, I'm getting it right:
<response>
<error>
[error number]
</error>
</response>
What is happening with the OK response? I get it because of file_get_contents?
If so, what else can I use? I heard of cURL but have no idea on how to use it :(
Thanks a lot
Upvotes: 1
Reputation: 259
I'm not sure to understand you question but maybe this can help you: http://php.net/manual/en/features.remote-files.php
or even directly using simplexml: http://php.net/manual/fr/function.simplexml-load-file.php
Upvotes: 0