Link to home
Start Free TrialLog in
Avatar of Mike Paradis
Mike Paradis

asked on

cUrl between two web server locks when payload is given

This is the code:
    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);
    }

Open in new window


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?
Avatar of David Favor
David Favor
Flag of United States of America image

Nearly impossible to answer without having your actual API endpoint login credentials to verify what's occurring... and...

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.
ASKER CERTIFIED SOLUTION
Avatar of Mike Paradis
Mike Paradis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Paradis
Mike Paradis

ASKER

Found an answer directly in Yii.