Pinterest API for follow: LIMIT 1000 hits per hour per user access token https://api.pinterest.com/v1/me/following/users/?access_token=XXXXXXXX&user=XXXXXXX
+-------------+---------------------+------------------+
| userId | usertoFollowPerHour | maxUserAvailable |
+-------------+---------------------+------------------+
| 1 | 100 | 1000|
| 2 | 200 | 9000|
| 3 | 210 | 100|
| 4 | 300 | 1100|
| 5 | 300 | 900|
| . | | |
| . | | |
| . | | |
| n | n| n|
+-------------+---------------------+------------------+
Now I have to follow users for particular userID so that: I can follow users within limit and Pinterest do not block my profile
Currently, I am doing it by: A cron that will hit URL of the following function after every 3 hours A function that is:
calculating user to follow in one loop for Eg:
1. let currentTime = 1:00
and endTime = 2:00
user to follow = 300
timeRemaining = currentTime-endTime => 60 minutes
300/60 = 5 => ceil(5)=5
2. it will fetch five user in one iteration from Pinterest
3. than it will follow them one by one in second loop
4. after that again it will calculate until userToFllow become 0
300-5=295 => ceil(295/timeRemaining(let 59)) = 5
5. again 1 for next user

By above logic some of our users got banned/blocked may be due to Pinterest reason
Please suggest me answer with a solution if possible, whether I should use multi thread or more functions to do this async. I will be happy if it can be accomplished by CodeIgniter only
So the follow this logic in your api:
Each app (with a unique app ID) is allowed 1000 calls per hour for each unique user token. The 60-minute window is a sliding window based on when you make your first request. If you hit your rate limit, you’ll only have to wait a max of 1 hour to get a few more requests.
Every API response returns a header that gives you an update about rate limiting. X-Ratelimit-Limit is the rate limit for that specific request, and X-Ratelimit-Remaining is the number of requests you have left in the 60-minute window.
X-Ratelimit-Limit: 1000
X-Ratelimit-Remaining: 890
Add this condition in your api response header and checking how many remaining .
If you exceed your rate limit for a given endpoint, you’ll get a 429 “Too many requests” error code.
Check for this condition response and trigger email to yourself if the http Code is 429 or log into the log file.
PS: Did not try this but sure it will help you to solve your problem in same way.
Source: Pintrest Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With