Hello Friends,
I am new to mautic. I have setup webhook. Whenever new lead is come sms should goes to user.
Here is my code which tried but it is not working :-
Code:
class webhookTest {
/**
* Log a message to a file
*
* @param mixed $message
* @param string $type [info|error|request]
*/
function objectToArray($d)
{
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return array_map(__FUNCTION__, $d);
} else {
// Return array
return $d;
}
}
public function log($message, $type = 'info')
{
date_default_timezone_set('Asia/Kolkata');
$obj = json_decode($message);
$new_array = $this->objectToArray($obj);
$phone = $new_array['mautic.form_on_submit'][0]['submission']['results']['phone'];
/* Sms code will come here */
}
public function getRequest()
{
$rawData = file_get_contents("php://input");
$this->log($rawData, 'request');
return json_decode($rawData);
}
}
$webhook = new webhookTest;
$requestData = $webhook->getRequest();
Can anyone tell me what's wrong i am doing?