我有一个我正在尝试配置的 Webhook。用户填写表单,它也连接到 Webhook 以将表单数据发送到另一个位置。似乎不起作用,当我提交表单时,webhook 目的地似乎没有处理/发送数据。
这是 Json 数据:
data.json { "Account_Name": [ "Test Name" ], "Email": [ "test@test.com" ], "Phone": [ "5555555555" ], "camp_id": [ "18052" ], "hs_a_t": [ "1360223458579" ], "ip_address": [ "" ], "referrer": [ "" ], "source": [ "3" ], "time_submitted": [ "07:51 AM UTC" ] }
data.xml <?xml version='1.0'?> <form_data> <Account_Name>Test Name</Account_Name> <Phone>5555555555</Phone> <Email>test@test.com</Email> <camp_id>18052</camp_id> <hs_a_t>1360223458579</hs_a_t> <source>3</source> <referrer/> <ip_address></ip_address> <time_submitted>07:51 AM UTC</time_submitted> </form_data>
extra_data.json { "rapleaf": {} }
extra_data.xml <?xml version='1.0'?> <extra_data> <rapleaf/> </extra_data>
page_id a75948fc-70f6-11e2-8dd8-12313e008101
page_name Test
page_url http://unbouncepages.com/test33333
variant a
这是 webhook 指向的 php 代码:
<?php
function stripslashes_deep($value) {
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
if (get_magic_quotes_gpc()) {
$unescaped_post_data = stripslashes_deep($_POST);
} else {
$unescaped_post_data = $_POST;
}
$form_data = json_decode($unescaped_post_data['data_json']);
/*******************************
PARSE DATA FROM UNBOUNCE
*******************************/
$email_address = $form_data->email[0];
$page_id = $_POST['page_id']; //Unbounce Page ID
$page_url = $_POST['page_url']; //Unbounce Page URL
$variant = $_POST['variant']; //Unbounce Page Variant
function mytheme_post_to_another_script($form)
{
// Rewrite the post variables
$post = array(
'Account_Name' => $_POST['name'], // Change iphorm_X_X to name field unique ID
'Email' => $_POST['email_address'], // Change iphorm_X_X to email field unique ID
'Phone' => $_POST['phone_number'], // Change iphorm_X_X to phone field unique ID
'Website_URL' => $_POST['iphorm_1_4'],
'Camp_ID' => $_POST['Camp_ID'],
'Source' => $_POST['Source'],
'Email_List_ID' => $_POST['Email_List_ID'],
'hs_a_t' => $_POST['hs_a_t']
);
// Create a new cURL resource
$ch = curl_init();
// Set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, 'http://Reports.rankupmedia.com/Client/Sales/Lead/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
// Grab URL and pass it to the browser
curl_exec($ch);
// Close cURL resource, and free up system resources
curl_close($ch);
}
?>