# Send Sms with webhook

**URL:** <https://forum.mautic.org/t/send-sms-with-webhook/4168>\
**Category:** Product Support\
**Created:** [June 28, 2016, 1:03pm UTC](https://forum.mautic.org/t/send-sms-with-webhook/4168 "2016-06-28T13:03:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://forum.mautic.org/u/pramod)\
**Post date:** [June 28, 2016, 1:03pm UTC](https://forum.mautic.org/t/send-sms-with-webhook/4168/1 "2016-06-28T13:03:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pramod](https://avatars.discourse-cdn.com/v4/letter/p/71c47a/32.png) [@pramod](https://forum.mautic.org/u/pramod)\
**Post date:** [June 28, 2016, 1:03pm UTC](https://forum.mautic.org/t/send-sms-with-webhook/4168/2 "2016-06-28T13:03:44Z")

</div>

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();[/code]

Can anyone tell me what’s wrong i am doing?
