carbocation / go-instagram

Go library for accessing Instagram REST and Search APIs
BSD 2-Clause "Simplified" License
51 stars 20 forks source link

Instagram Tags endpoint results type differ from expected #13

Closed gloob closed 8 years ago

gloob commented 8 years ago

Hi,

I'm starting to use this library for an Instagram search service into a Telegram bot gfxBot. Because the only searchable entity is Tags, I'm using it extensively.

Currently the Tags part is failing, by whatever reason Instagram is returning this JSON structure for search method:

https://api.instagram.com/v1/tags/search?q=test&access_token=YOUR_ACCESS_TOKEN

{
   "meta":{
      "code":200
   },
   "data":[
      {
         "media_count":1674374.0,
         "name":"test"
      },

      ... more values ...

      {
         "media_count":24839.0,
         "name":"testtrack"
      }
   ]
}

https://api.instagram.com/v1/tags/test&access_token=YOUR_ACCESS_TOKEN

{
   "meta":{
      "code":200
   },
   "data":{
      "media_count":1675998,
      "name":"test"
   }
}

In the tags search results is returning the media_count with dot notation making the go json parser to fail, as this:

Tags.Search returned error: json: cannot unmarshal number 1674374.0 into Go value of type int

I didn't find anything useful in the Instagram developers documentation about this difference and maybe its a bug in their side or just the way they are generating the number value for media_count in search method.

carbocation commented 8 years ago

Eww, you're right: They are now returning floats, rather than integers, for the media_count. That's nonsensical, breaking, and will require type conversions in our code if they are going to continue using floats.

carbocation commented 8 years ago

Is this resolved by Instagram? Their demo responses look correct now.

gloob commented 8 years ago

Just checked, it seems they are returning integers again. Although it seems that the second request of my initial comment is not working, probably they are changing the API too. Anyway we can close this.

Thanks!

carbocation commented 8 years ago

Thanks. Issue fixed by Instagram.