Giter Club home page Giter Club logo

Comments (12)

dirkgroenen avatar dirkgroenen commented on June 10, 2024 1

Interesting, thanks @zigstum.
Feel free to open a PR if you feel like solving this. Otherwise I'll see if I can make some time soon to fix it.

from pinterest-api-php.

dirkgroenen avatar dirkgroenen commented on June 10, 2024

Hmm that's weird, getRateLimit() and getRateLimitRemaining() both use the same mechanism to fetch the header which gives us that information. Just confirmed with the Pinterest API Docs and nothing seems to have changed.

I'm not in the position right now to actually check it, but code-wise is should work.

Is there any additional information you can provide?

from pinterest-api-php.

zigstum avatar zigstum commented on June 10, 2024

dumping the $header var in the two appropriate functions in Pinterest.php shows that no headers are being returned - ie. the $header var comes up null.

It seems that the getRateLimit is working because it is a default value of 1000 if no header exists:
return (isset($header['X-Ratelimit-Limit']) ? $header['X-Ratelimit-Limit'] : 1000);

So, neither of those functions are actually working.

from pinterest-api-php.

zigstum avatar zigstum commented on June 10, 2024

Running the API call through 'Postman' shows that the headers are present in the response:

Access-Control-Allow-Origin →*
Age →0
Cache-Control →private
Connection →keep-alive
Content-Length →131
Content-Type →application/json
Date →Thu, 16 Nov 2017 17:49:17 GMT
Pinterest-Generated-By →
Pinterest-Version →1294124
X-Content-Type-Options →nosniff
X-Pinterest-RID →XXXX
X-Ratelimit-Limit →200
X-Ratelimit-Remaining →25

Dumping the value of $this->headers in Request.php shows that the headers do exist:

// Get headers from last request
        $this->headers = $ch->getHeaders();
        dd($this->headers);

// this gives:

array:16 [
  0 => "HTTP/1.1 200 OK\r"
  "Access-Control-Allow-Origin" => "*"
  "Age" => "0"
  "Cache-Control" => "private"
  "Content-Type" => "application/json"
  "Pinterest-Version" => "1294124"
  "X-Content-Type-Options" => "nosniff"
  "X-Pinterest-RID" => "XXXX"
  "X-Ratelimit-Limit" => "200"
  "X-Ratelimit-Remaining" => "159"
  "Content-Length" => "369"
  "Date" => "Thu, 16 Nov 2017 18:43:01 GMT"
  "Connection" => "keep-alive"
  "Pinterest-Generated-By" => ""
  1 => "\r"
  2 => ""
]

So, the headers are received, but they are not propagating to the function that is called.

from pinterest-api-php.

sfatfarma avatar sfatfarma commented on June 10, 2024

Hello,

First of all, thank you for the great API.

Found the same issue myself, getRateLimitRemaining() returns unknown.

Also, I got rate limited today, so this info would be great to have. :)

Regards,
Szabi.

from pinterest-api-php.

sfatfarma avatar sfatfarma commented on June 10, 2024

Well, I have investigated a bit more on this issue, and it seems that getRateLimitRemaining() works, but only if you make a direct API call to any endpoint, before calling it.

So, if you initialize the framework and immediately check getRateLimitRemaining(), it will return 'unknown'.

from pinterest-api-php.

dirkgroenen avatar dirkgroenen commented on June 10, 2024

Seems like the correct headers are used (X-Ratelimit-Remaining). Anybody who can confirm this is indeed a code issue, or if it's related to @sfatfarma's explanation?

from pinterest-api-php.

dirkgroenen avatar dirkgroenen commented on June 10, 2024

The getRateLimitRemaining() method uses the headers from its last made request. If you initialize the framework and immediately check the remaining limit you will indeed get the unknown value.

I guess this could be improved in the documentation, or maybe add something to the unknown value so users know that they should make a request first.

from pinterest-api-php.

sfatfarma avatar sfatfarma commented on June 10, 2024

Thank you for the explanations. :)

from pinterest-api-php.

cheekyboots avatar cheekyboots commented on June 10, 2024

I had the same problem. I fixed it with a change to capitalization. The headers I got were this:

X-RateLimit...

In the code it has:
X-Ratelimit...

The lowercase L is correct according to Pinterest documentation, but not according to what actually got returned when dumping $pinterest->request;

from pinterest-api-php.

cheekyboots avatar cheekyboots commented on June 10, 2024

Actually it seems like it is sometimes one and sometimes the other, so you have to check both.

from pinterest-api-php.

dirkgroenen avatar dirkgroenen commented on June 10, 2024

This will be in release 0.2.12

from pinterest-api-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.