title: Instagram API Subscription, how to get post?
body: <p>I'm working to understand how to get the results of a Instagram Subscription that looks for a specific tag. Ultimately, what I would like to do is as images are posted with the tag I'm looking for add the link to the photo as well as the username to a database. </p>
  
  <p>I was able to create my subscription no problem but now I'm not sure how to get the POST information from the subscription.</p>
  
  <p>Working with two files...subscribe.php and callback.php</p>
  
  <p><strong>subscribe.php</strong></p>
  
  <pre><code>&lt;?php
  
  //ALL YOUR IMPORTANT API INFO
  $client_id = 'XXX';
  $client_secret = 'XXX';
  $object = 'tag';
  $object_id = 'taglookingfor';
  $aspect = 'media';
  $verify_token='';
  $callback_url = '(full URL here)/callback.php';
  
  
  //SETTING UP THE CURL SETTINGS...
  $attachment =  array(
  'client_id' =&gt; $client_id,
  'client_secret' =&gt; $client_secret,
  'object' =&gt; $object,
  'object_id' =&gt; $object_id,
  'aspect' =&gt; $aspect,
  'verify_token' =&gt; $verify_token,
  'callback_url'=&gt;$callback_url
  );
  
  //URL TO THE INSTAGRAM API FUNCTION
  $url = "https://api.instagram.com/v1/subscriptions/";
  
  $ch = curl_init();
  
  //EXECUTE THE CURL...
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
  $result = curl_exec($ch);
  curl_close ($ch);
  
  //PRINT THE RESULTS OF THE SUBSCRIPTION, IF ALL GOES WELL YOU'LL SEE A 200
  print_r($result);
  
  
  ?&gt;
  </code></pre>
  
  <p><strong>callback.php</strong></p>
  
  <pre><code> &lt;?php
  
  if (isset ($_GET['hub_challenge'])){
      echo $_GET['hub_challenge'];
  }
  
  //This is an update
  else {
  
      $myString = file_get_contents('php://input');
      $answer = json_decode($myString);
      echo $answer;
  }
  
  ?&gt;
  </code></pre>
  
  <p>In my callback.php I'm attempting to echo out the results of the json_decode...but that also begs the question how will I catch that echo? Sorry, this might be really silly but how do I catch the moment when the callback.php script is being fired by a new image with the specific tag I'm looking for. As I mentioned what I hope to do is take the info in the $answer and insert some of the info into a database.</p>
  
  <p>I'm new at this so any help would be greatly appreciated.
  Thanks a million!!</p>