title: How to handle IBM Watson asynchronous callback events in php
body: <p>I am trying to get asynchronous callback to work for IBM Watson speech to text.</p>
  
  <p>I got the curl function work </p>
  
  <pre><code>curl -X POST -u "c94c7025-09f5-4cee-94dd-8f73348b60d8":"4TOriExZooKh" \
  --header "Content-Type: audio/wav" \
  --data-binary @uploads/001528fe-9545-4c3f-9d0d-aec4cd61caee.wav \
  "https://stream.watsonplatform.net/speech-to-text/api/v1/recognitions?callback_url=http://34.234.215.13/callback.php&amp;model=en-US_NarrowbandModel&amp;profanity_filter=false&amp;events=recognitions.completed_with_results&amp;user_token=audio&amp;results_ttl=10"
  </code></pre>
  
  <p>From my understanding is that the results or notification should be sent as POST to the call back URL</p>
  
  <p><a href="https://console.bluemix.net/docs/services/speech-to-text/async.html#create" rel="nofollow noreferrer">https://console.bluemix.net/docs/services/speech-to-text/async.html#create</a></p>
  
  <p>The above code should be sending the completed results over to <em>callback.php</em></p>
  
  <pre><code>callback.php
  &lt;?php
  header('Content-Type:text/plain');
  echo $_GET["challenge_string"];
  foreach ($_POST as $key =&gt; $value)
      error_log($key . "--" . $value);
  </code></pre>
  
  <p>The echo is for the url registration and then for any data sent over POST I am passing it into the foreach loop.</p>
  
  <p>But I am not getting any data or results at all after the conversion is done.</p>
  
  <pre><code>access log
  [14/Oct/2017:00:22:39 +0000] "POST /callback.php HTTP/1.1" 200 166 "-" "Jersey/2.22.1 (Apache HttpClient 4.5)"
  
  error log
  [:error] [pid 2046] [client 169.48.114.147:54645] PHP Notice:  Undefined index: challenge_string in /var/www/html/callback.php on line 10
  </code></pre>
  
  <p>I am not able to understand what is wrong? I was able to get it work when I make synchronous calls ie one POST after another.</p>