Smartsheet Api интеграция

я использую контактную форму 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

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

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]