Note that there are some explanatory texts on larger screens.

plurals
  1. POInstagram Api with MongoDB and PHP
    primarykey
    data
    text
    <p>I am have been wrestling with the realtime instagram api for a class project. I have a subscription and callback script that pushes the data into mongoDB. Everything works great and I receive updates, but the $data array is empty on all of them. I can't seem to find why I'm not receiving data back with the updates. Any help would be appreciated. Here is my code and I attached a screenshot of my mongoDB result. </p> <p>***Subscribe script</p> <pre><code>&lt;?php //Subscribe //ALL YOUR IMPORTANT API INFO $client_id = 'xxxxxxxxxxxxxxxxxxxx'; $client_secret = 'xxxxxxxxxxxxxxxxxxxxxx'; $object = 'geography'; $lat = '39.73'; $lng = '-104.98'; $radius = '5000'; $aspect = 'media'; $verify_token=''; $callback_url = 'http://www.callback.com'; //SETTING UP THE CURL SETTINGS $attachment = array( 'client_id' =&gt; $client_id, 'client_secret' =&gt; $client_secret, 'object' =&gt; $object, 'lat' =&gt; $lat, 'lng' =&gt; $lng, 'radius' =&gt; $radius, '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 YOULL SEE A 200 print_r($result); ?&gt; </code></pre> <p><em>*</em>*Callback script</p> <pre><code>&lt;?php //Callback if (isset ($_GET['hub_challenge'])){ echo $_GET['hub_challenge']; } else { //database config $dbhost = '@myserver'; $dbname = 'test'; //connect to database $m = new Mongo("mongodb://$dbhost"); $db = $m-&gt;$dbname; //select the collection $collection = $db-&gt;instagram; //This is an update $myString = file_get_contents('php://input'); $ALL = date("F j, Y, g:i a")." ".$myString."\r\n"; file_put_contents('activity1.log', $ALL, FILE_APPEND); $answer = json_decode($myString); $collection-&gt;save($answer); } ?&gt; </code></pre> <p>When I open RoboMongo I get the keys I recieve are object id, changed aspect, object, time, subscription id. Then there is a data array that is always empty. I can't figure how to the info from this. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload