Comments (12)
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.
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.
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.
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.
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.
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.
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.
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.
Thank you for the explanations. :)
from pinterest-api-php.
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.
Actually it seems like it is sometimes one and sometimes the other, so you have to check both.
from pinterest-api-php.
This will be in release 0.2.12
from pinterest-api-php.
Related Issues (20)
- Fatal error Pinterest error (code: 500) HOT 1
- Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found HOT 1
- Laravel 6 compatibility? HOT 3
- Not pining HOT 4
- You should be redirected automatically to target URL HOT 1
- pin send error HOT 5
- can't pin an image to Pinterest but no error sent HOT 6
- request empty in create pin HOT 3
- getMeBoards not working HOT 2
- how can be scheduled images to go live at a later date on pinterest using api in php? HOT 1
- invalid_grant when trying to convert a JS access code for an access_token HOT 9
- ACCESS_TOKEN Pin Sharing HOT 2
- Project status HOT 1
- getting error message "API method not found"
- Support of Pinterest API (v5) HOT 3
- Video pin?
- How to use fromBoard method? HOT 2
- New Section HOT 1
- Request to correct instructions HOT 2
- Sanitize board name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinterest-api-php.