Created
May 6, 2021 21:35
-
-
Save KravMaguy/278d9a3198d6ea81f6aeb1838d1b794c to your computer and use it in GitHub Desktop.
php only post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'secrets.php'; | |
add_action( 'wpcf7_mail_sent', 'cf7_form_send_to_acculynx' ); | |
function cf7_form_send_to_acculynx($contact_form) { | |
$submission=WPCF7_Submission::get_instance(); | |
if($submission){ | |
$posted_data=$submission->get_posted_data(); | |
$name=$posted_data['your-name']; | |
$email=$posted_data['your-email']; | |
$phone=$posted_data['telephone']; | |
$address=$posted_data['your-address']; | |
$message=$posted_data['your-message']; | |
$url="https://api.acculynx.com/api/v1/leads"; | |
$body=[ | |
'firstName'=> $name, | |
'emailAddress'=> $email, | |
'phoneNumber1'=> $phone, | |
'jobCategory'=> "residential", | |
'street'=> $address, | |
'notes'=> $message, | |
]; | |
$body = wp_json_encode($body); | |
$args=array( | |
'headers'=>array( | |
'Authorization' => 'Bearer '. $key, | |
'Content-Type' => 'application/json', | |
), | |
'method'=>'POST', | |
'body'=>$body, | |
); | |
wp_remote_post($url,$args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment