Home › Forums › Quform WordPress › Email – API
- This topic has 1 reply, 2 voices, and was last updated 2 years, 11 months ago by Ally.
- AuthorPosts
- December 2, 2021 at 4:15 pm #33765theodor.nedelea@livingtech.chParticipant
Dear QuForm team
Before we send the form, we would like to send an API request (Post) … everything works great, but after calling “$ resp = curl_exec ($ ch)”
no value in the response, but the data has arrived at the end point.We have chosen the Quform v2 hook “QUFORM_PRE_PROCESS_X” for this
is there any reason why the response is empty and not even true | returns false?
Code:
$ch = curl_init();
//entpoint url
$url = “endpoint url”;
$apiKey = “api key”;//post data (id’s are replaced in real code)
$posts = array(
‘customerName’ => $_POST[‘quform_X_X’],
‘customerSurname’ => $_POST[‘quform_X_X’],
‘company’ => $_POST[‘quform_X_X’],
’email’ => $_POST[‘quform_X_X’]
‘phone’ => $_POST[‘quform_X_X’]
);//set url
curl_setopt($ch, CURLOPT_URL, $url);//indicate post
curl_setopt($ch, CURLOPT_POST, true);//add form as json string as post data
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($posts, true));//set the content type to application/json
//set form auth apikey
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type:application/json’,
‘FormApiKey: ‘.$apiKey.”
));$response = curl_exec($ch);
//set the response to the hiddenfield to use the value in the mail
$_POST[‘quform_X_X’] = $responsecurl_close($ch);
December 3, 2021 at 10:17 am #33769AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.