cosenary / Instagram-PHP-API

An easy-to-use PHP Class for accessing Instagram's API.
http://cosenary.github.com/Instagram-PHP-API
BSD 3-Clause "New" or "Revised" License
1.46k stars 782 forks source link

$limit=0 default no longer works #121

Open smvanbru opened 9 years ago

smvanbru commented 9 years ago

Instagram has started raising errors on some API calls when the count value is set to 0. So setting 0 as a default value is no longer a good default. Probably want to start requiring limit to be set, or defaulting it to what ever Instagram used as a default when 0 was passed as the count parameter.

vinkla commented 9 years ago

I totally agree. This is also discussed in #120 and in #122.

smvanbru commented 9 years ago

Instagram made the change on Sunday April 5/Monday April 6 -- My code had been working fine till then, and then started falling over. Made even worse because they raised a different type of error than I'd previously encountered, so my code didn't handle it as well as it could have.

I've been able to resolve the issue in my own code by simply specifying a limit all the time. But we probably don't want bad defaults in this code!

vinkla commented 9 years ago

I think we should remove all limit values and only accept an array of parameters. Currently we have problems such as described in #118 where the developers can't specify anything else but the limit.

smvanbru commented 9 years ago

I'd think that for any parameter Instagram makes mandatory this library should make it mandatory too. And count (limit) now does seem to be a mandatory parameter. Perhaps after all the mandatory parameters, it could optionally accept an array of additional parameters.

vinkla commented 9 years ago

Are you sure its mandatory? What happens if we don't send any parameters at all? I can't find anything about it in the documentation. Though, I agree with you. If Instagram says something is mandatory it should work the same in our package.

smvanbru commented 9 years ago

I'm not sure. I assumed it was mandatory since this library set it to 0 when limit wasn't passed in. I haven't tried making the Instagram call with that parameter not set.

But given that they just decided (without notifying their existing API users) to throw an error on count=0 rather than substituting their default count like they had been doing for a long time, I'm nervous about assuming anything at this point.

Now in their defence, I'd noticed them having a lot more server issues the previous several days than normal, so it's possible they did this in order to address a load issue or something. At the very least, breaking a bunch of apps that use their API is an effective way to reduce the load on their servers. ;-)

ghost commented 9 years ago

I managed to get my code running with a quick fix like the following

public function getUserFeed($limit = 0) {
        if($limit>0) {
            return $this->_makeCall('users/self/feed', true, array('count' => $limit));
        }else{
            return $this->_makeCall('users/self/feed', true);
        }

It isn't pretty but it work fine without having to edit the methods call. Instagram now ask for either a count parameter over 0 or no count parameter at all. I figured it was the best way to deal with it will we figure a way to solve it properly.