構成しようとしている 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);
}
?>