Hi guys,
I was wondering if you could help me. I have this code which should send a call to a RESTful web service (which creates a new user in a database). My code is executing without any errors (that I can see) however the user doesn't get created.
$url = 'http://127.0.0.1:85/AccountCreator.ashx';
$curl_post_data = array(
'$companyName' =>$companyName,
'$mainContact' =>$mainContact,
'$telephone1' =>$telephone1,
'$email' => $email,
'$contact2' => $contact2,
'$telephone2' => $telephone2,
'$email2' => $email2,
'$package' => $package
);
foreach($curl_post_data as $key=>$value) {$fields_string.=$key. '=' .$value.'&';
}
rtrim($fields_string, '&');
//die("Test: ".$fields_string);
$ch = curl_init();
curl_setopt ($ch, CURLOPT, $url);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
I'm fairly new to PHP also, so I just can't see where I'm doing wrong. I have access to the server also - is there anything I can check on that which would indicate if the web service is being called or not?
I've also read this in http://php.net/manual/en/function.curl-setopt.php...
I don't think my PHP document is set to multipart/form-data - Would this affect it?
I have also tried it like this with the port number,
$url = 'http://127.0.0.1/AccountCreator.ashx';
$curl_post_data = array(
'$companyName' =>$companyName,
'$mainContact' =>$mainContact,
'$telephone1' =>$telephone1,
'$email' => $email,
'$contact2' => $contact2,
'$telephone2' => $telephone2,
'$email2' => $email2,
'$package' => $package
);
foreach($curl_post_data as $key=>$value) {$fields_string.=$key. '=' .$value.'&';
}
rtrim($fields_string, '&');
//die("Test: ".$fields_string);
$ch = curl_init();
curl_setopt ($ch, CURLOPT, $url);
curl_setopt ($ch, CURLOPT_PORT , 85);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);