Sindbad~EG File Manager
Current Path : /proc/12916/task/19062/cwd/ |
|
Current File : //proc/12916/task/19062/cwd/post_data_to_leads_api.php |
<?php
require( 'wp-load.php' );
global $wpdb;
$query = "SELECT * FROM `".$wpdb->prefix."db7_forms` WHERE form_post_id = 12609 LIMIT 1";
$cf_rows = $wpdb->get_results($query, ARRAY_A);
//echo "<pre>";print_r($cf_rows);exit;
foreach( $cf_rows as $cf_row ) {
$cf_form_data = unserialize($cf_row['form_value']);
//echo "<pre>";print_r($cf_form_data);
$lead_data['lead']['first_name'] = $cf_form_data['your-first-name'];
$lead_data['lead']['last_name'] = $cf_form_data['your-last-name'];
$lead_data['lead']['email'] = $cf_form_data['your-email'];
$lead_data['lead']['mobile_number'] = $cf_form_data['Phone'];
$lead_data['lead']['lead_source_id'] = '5000300115';
$lead_data['lead']['company']['name'] = $cf_form_data['your-company-name'];
$lead_data['lead']['custom_field']['cf_page_url'] = str_replace("/","/",$cf_form_data['page-url']);
//echo str_replace("/","/",$cf_form_data['page-url']);exit;
//echo "<pre>";print_r($lead_data);
//exit;
$payload = json_encode( $lead_data );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://bhartisofttech.freshsales.io/api/leads");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = [
'Authorization: Token token=bvSc3h3saPstiRkaLZJbPQ',
'Content-Type:application/json'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$curl_response = curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
echo $error_msg;
echo "<hr>";
}
curl_close ($ch);
echo "<pre>";print_r($curl_response);
echo "<hr>";
$decoded_curl_response = json_decode($curl_response, true);
echo "<pre>";print_r($decoded_curl_response);
}
?>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists