Skip to content
Advertisement

Somehow the API is not getting my parameters sent via cURL, how could I get this working?

I have the following cURL function:

function getReferalURL($userMail){
  $dataToSend = array(
     'key: kewbhfbi87324y3rb3r2837r3brikbfwef23ibwjkfbkjfwkjfb',
     'email:laura@hotmail.com'
  );

  $curl = curl_init();
  $curlOptions = array(
     CURLOPT_URL            => 'https://api.leaddyno.com/v1/affiliates/by_email',
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_POST           => false,
     CURLOPT_HTTPHEADER     => $dataToSend,
  );

  curl_setopt_array($curl, $curlOptions);

  $afiliateData = curl_exec($curl);

  if (!$afiliateData) {
     return curl_error($curl);
  } else {
     return $afiliateData;
  }
}

All that I’m getting as a response is that the email is missing.

I’ve read the documentation, all they have about this specific requisition is:

Definition: GET https://api.leaddyno.com/v1/affiliates/by_email

Curl:

$ curl https://api.leaddyno.com/v1/affiliates/by_email -G 
       -d email=example@example.com 
       -d key=[YOUR_PRIVATE_KEY]

That’s a dummy private key, of course. I would appreciate any help.

Advertisement

Answer

This:

$dataToSend = array(
    'key: kewbhfbi87324y3rb3r2837r3brikbfwef23ibwjkfbkjfwkjfb',
    'email:laura@hotmail.com'
);

is not the sort of array it’s expecting.

$dataToSend = array(
    'key' => 'kewbhfbi87324y3rb3r2837r3brikbfwef23ibwjkfbkjfwkjfb',
    'email' => 'laura@hotmail.com'
);

is likely what you need.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement