php - API send email and Password using CURL


I have written some code into a plugin for Wordpress that when the User hits the submit button their information is stored in the WP database and is also sent to a third party website with their email and password using JSON protocalls.

this is the code I use (the "$bemail" and $password are referring to earlier parts of the code in the same file):

$url = "";
$data = array(
    'email'     => $_POST['$bemail'],
    'password'  => $_POST['$password'],
$content = json_encode($data);
$curl = curl_init($url);
$apikey = "xxxx";
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    ' ' . $apikey,
    'Accept: application/json',
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

I get an error with a response from the 3rd party website with something like:

"error: email and password cannot be blank"

which tells me that the email and password is not being sent.

what am I missing here?

Thank you.




To tell the receiving server to expect JSON, use theContent-Type header instead ofAccept:

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    ' ' . $apikey,
    // remove this line -> 'Accept: application/json',
    'Content-Type: application/json'



The first thing I would suggest is to just use our PHP API client which you can find here:

The documentation for creating a login is here:

You can also see what is being received on the server side by logging into your account and going to

If you have any further questions about getting set up with the API, please reach out to our customer support directly!

People are also looking for solutions to the problem: php - Link does not work without http:// protocols


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.