I have successfully created a Real-Time subscription for geography in Instagram for my location:
lat 1.436629
long 38.438239
Radius: 1000
The subscription call gave this geography id: 12932150
After this, I posted a picture on Instagram by tagging my current location with a custom name. I then noticed that Instagram did not ping my call-back-url. If Instagram did ping the call-back-url, the geography id is to be picked up from the ping, and used in calling the media/recent endpoint on geographies.
I did this manually. A call to "https://api.instagram.com/v1/geographies/12932150/media/recent?client_id=XXXXX" returns empty results: {"pagination":{},"meta":{"code":200},"data":[]} That means the post was not registered for the geography id within 1000 meters of the center.
But, calling media/search endpoint: "https://api.instagram.com/v1/media/search?lat=1.436629&lng=38.438239&client_id=XXXX&count=200&distance=1000" gave 69 results with my post at the top.
Is there something wrong in my code for Real-time subscription? Or am I missing something important here. Please help.
This is the code for subscription:
<?php
$client_id = 'XXXX';
$client_secret = 'XXXX';
$redirect_uri = 'http://XXXX/igcallback.php';
$apiData = array(
'client_id' => $client_id,
'client_secret' => $client_secret,
'aspect' => "media",
'object' => "geography",
'lat' => "1.436629",
'lng' => "38.438239",
'radius' => '1000',
'callback_url' => $redirect_uri
);
$apiHost = 'https://api.instagram.com/v1/subscriptions/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiHost);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$jsonData = curl_exec($ch);
curl_close($ch);
var_dump($jsonData);