Smartsheet Api integration

i am using contact form 7 and i want to send contact form data to my sheet

below the code to get contact form data

Read More
add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' ); 

function your_wpcf7_mail_sent_function( $contact_form ) {
    $title = $contact_form->title;
    $submission = WPCF7_Submission::get_instance();

    if ( $submission ) {
        $posted_data = $submission->get_posted_data();
    }



   if ( 'Contact form' == $title ) {

        $yourName = $posted_data['your-name'];
        $yourEmail = $posted_data['your-email'];
        $yourPhone = $posted_data['phone'];


   }
}

How can i send contact form data to my sheet?

https://www.smartsheet.com

Related posts

Leave a Reply

1 comment

  1. Now I have done.

    //smartsheet api integration with Contact Form 7
    add_action( 'wpcf7_mail_sent', 'your_wpcf7_mail_sent_function' ); 
    function your_wpcf7_mail_sent_function( $contact_form ) {
        $title = $contact_form->title;
        $submission = WPCF7_Submission::get_instance();
    
        if ( $submission ) {
            $posted_data = $submission->get_posted_data();
        }
    
    
    
       if ( 'Contact form' == $title ) {
    
            $yourName = $posted_data['your-name'];
            $yourEmail = $posted_data['your-email'];
            $yourPhone = $posted_data['phone'];
    
            // Insert your Smartsheet API Token here
            $accessToken = "xxxxxxxxxxxxxxx";
            // Create Headers Array for Curl
            $headers = array(
            "Authorization: Bearer ". $accessToken,
            "Content-Type: application/json"
            );
    
            $postfields = '{"toTop":true, 
                               "rows":[ 
                               {"cells": [ 
                               {"columnId": xxxxxxxxxxxx, "value": "'.$yourName.'"}, 
                               {"columnId": xxxxxxxxxxxx, "value": "'.$yourEmail.'"},
                               {"columnId": xxxxxxxxxxxx, "value": "'.$yourPhone.'"} 
                               ] } 
                               ] }';
            $curlSession = curl_init("https://api.smartsheet.com/1.1/sheet/{SHEETID}/rows");
            curl_setopt($curlSession, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($curlSession, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curlSession, CURLOPT_POSTFIELDS,  $postfields);
            curl_setopt($curlSession, CURLOPT_CUSTOMREQUEST, "POST");
            $sheetsResponse = curl_exec($curlSession);
            if (curl_errno($curlSession)) {
            print "Oh No! Error: " . curl_error($curlSession);
            } else {
            // Assign response to variable
            $sheetObj = json_decode($sheetsResponse);
            // close curlSession
            curl_close($curlSession);
            }
    
            /* Put your code here to manipulate the data - simples ;) */
      }
    }