0

I'm encountering a 504 Gateway Time-out error when attempting to make a cURL request in a WordPress environment. I've included the relevant code below:

    function welkvoxapi() {
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://wv{{wolkvox_server}}.wolkvox.com/api/v2/campaign.php?api=add_record&type_campaign={{type_campaign}}&campaign_id={{campaign_id}}&campaign_status={{campaign_status}}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'[{
            "customer_name": "namewv",
            "customer_last_name": "field_3d8268c",
            "customer_id": "field_d3976af",
            "city": "field_5dd4679",
            "opt1": "field_9f10881",
            "opt3": "field_6d254ff",
            "opt4": "field_363c904",
            "opt5": "field_a5de87f",
            "opt6": "field_dc05404",
            "opt7": "field_9a9a683",
            "opt8": "field_383d50f",
            "email": "field_8981d35"  


}]',
  CURLOPT_HTTPHEADER => array(
    'wolkvox-token: {{token}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


}
add_action('init', 'welkvoxapi');

I've added the following cURL code to my WordPress theme's functions.php file to interact with the Wolkvox API. However, when I save the code, the page doesn't load, and I encounter a "504 Gateway Time-out" error.

Wolkvoks Documentation.

Additionally, I am hosting my WordPress site on AWS, but I'm unsure if this is relevant to the encountered issue.

I have replaced the corresponding information in both the CURLOPT_URL and the token.

I would appreciate any guidance on resolving the "504 Gateway Time-out" issue. Additionally, if there are any considerations or best practices for integrating cURL requests in WordPress, I'd love to know.

1 Answer 1

0

The documentation wants you to insert the proper values where they use double curly braces.

To consume this API you must replace in the url {{{wolkvox_server}} by the nomenclature of the server of the operation.

In your particular account, they will give you the values you need to subsitute, meaning the server name, the campaign id, campaign type, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.