Mike Paradis
asked on
cUrl between two web server locks when payload is given
This is the code:
Whenever I enable sending the payload the server where the API is executed doesn't receive any call while if I don't send any payload (and modify the api on the receiver server) the called server does receive the call.
Any idea why this could happen or something I forgot to check?
public static function callApiUpdate($hostname, $ip)
{
$service_url = 'http://blablabla.com/api/updateDdns';
$ch = curl_init($service_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
/*
$payload = array(
'hostname' => $hostname,
'ip' => $ip,
);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS,CJSON::encode($payload));
*/
$response = curl_exec($ch);
/*
if ($response === false) {
$info = curl_getinfo($ch);
curl_close($ch);
}
*/
curl_close($ch);
}
Whenever I enable sending the payload the server where the API is executed doesn't receive any call while if I don't send any payload (and modify the api on the receiver server) the called server does receive the call.
Any idea why this could happen or something I forgot to check?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found an answer directly in Yii.
Couple of things to try.
1) Ensure your protocol is correct. You're using http: rather than https:, so anyone can listen in on your conversation + modify data.
Likely this should be https.
2) First get your entire conversation working using command line curl.
This may give you a clue as to what's occurring.
3) You have no error checking for any of your curl*() calls, so there's no way to tell what's occurring.
Add in return code checking for all your curl*() calls + they may also provide you clues to exact point of failure.