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.