【问题标题】:Smartsheet Api integrationSmartsheet API 集成
【发布时间】:2015-02-16 20:16:09
【问题描述】:

我正在使用联系表格 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'];


   }
}

如何将联系表单数据发送到我的工作表?

https://www.smartsheet.com

【问题讨论】:

标签: php wordpress smartsheet-api


【解决方案1】:

现在我已经完成了。

//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 ;) */
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-08
    • 2023-03-28
    • 2022-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    相关资源
    最近更新 更多