Email – API

Home Forums Quform WordPress Email – API

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33765

    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’] = $response

    curl_close($ch);

    #33769
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy