title: PHP Webhook - x-www-form-urlencode parse
body: <p>I am trying to build a kofi webhook parser and the data it sends is like this</p>
  <pre><code>data: {
  &quot;message_id&quot;:&quot;3a1fac0c-f960-4506-a60e-824979a74e74&quot;,
  &quot;kofi_transaction_id&quot;:&quot;0a1fac0c-f960-4506-a60e-824979a74e71&quot;,
  &quot;timestamp&quot;:&quot;2022-08-21T13:04:30Z&quot;,
  &quot;type&quot;:&quot;Donation&quot;,
  &quot;from_name&quot;:&quot;Ko-fi Team&quot;,
  &quot;message&quot;:&quot;Good luck with the integration!&quot;,
  &quot;amount&quot;:&quot;3.00&quot;,
  &quot;currency&quot;:&quot;USD&quot;,
  &quot;url&quot;:&quot;https://ko-fi.com&quot;
  &quot;is_subscription_payment&quot;:false
  &quot;is_first_subscription_payment&quot;:false}
  </code></pre>
  <p>The data is sent with a content type of application/x-www-form-urlencoded. A field named 'data' contains the payment infomation as a JSON string (as per the website information).</p>
  <p>I have a php script to try and obtain the data</p>
  <pre><code>parse_str(file_get_contents(&quot;php://input&quot;), $data);
  //$data = (object)$data;
  $data = json_decode(json_encode($data), true);
  var_dump($data);
  
  error_log($data-&gt;{'message_id'});
  </code></pre>
  <p>I cannot seem to get the value of message_id.</p>
  <p>POSTMAN returns</p>
  <pre><code>array(12) {
    [&quot;data&quot;]=&gt;
    string(2) &quot; {&quot;
    [&quot;&quot;message_id&quot;&quot;]=&gt;
    string(39) &quot;&quot;3a1fac0c-f960-4506-a60e-824979a74e74&quot;,&quot;
    [&quot;&quot;kofi_transaction_id&quot;&quot;]=&gt;
    string(39) &quot;&quot;0a1fac0c-f960-4506-a60e-824979a74e71&quot;,&quot;
    [&quot;&quot;timestamp&quot;&quot;]=&gt;
    string(23) &quot;&quot;2022-08-21T13:04:30Z&quot;,&quot;
    [&quot;&quot;type&quot;&quot;]=&gt;
    string(11) &quot;&quot;Donation&quot;,&quot;
    [&quot;&quot;from_name&quot;&quot;]=&gt;
    string(13) &quot;&quot;Ko-fi Team&quot;,&quot;
    [&quot;&quot;message&quot;&quot;]=&gt;
    string(34) &quot;&quot;Good luck with the integration!&quot;,&quot;
    [&quot;&quot;amount&quot;&quot;]=&gt;
    string(7) &quot;&quot;3.00&quot;,&quot;
    [&quot;&quot;currency&quot;&quot;]=&gt;
    string(6) &quot;&quot;USD&quot;,&quot;
    [&quot;&quot;url&quot;&quot;]=&gt;
    string(19) &quot;&quot;https://ko-fi.com&quot;&quot;
    [&quot;&quot;is_subscription_payment&quot;&quot;]=&gt;
    string(5) &quot;false&quot;
    [&quot;&quot;is_first_subscription_payment&quot;&quot;]=&gt;
    string(6) &quot;false}&quot;
  }
  </code></pre>
  <p>I am not convinced the data being sent by postman is accurate though, it formats it weirdly.</p>
  <p>Please can someone help me with what I am doing wrong? I basically want to receive the data and pull values from the data received which I am going to push in to a database.</p>