Skip to content

get_subscriber_id() causes 429 "Too many requests" API error when total pages > 120 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
modelm opened this issue Jul 15, 2021 · 5 comments

Comments

@modelm
Copy link

modelm commented Jul 15, 2021

The exact number of pages seems to vary, but calling this function is very slow and eventually causes the API to throw a 429 error for an account with lots of subscribers, because it queries the API for all subscribers and searches the results instead of searching the API directly for the provided email.

It is possible to search by email when listing subscribers using the email_address parameter according to https://developers.convertkit.com/#list-subscribers

Adding the email_address parameter to $options in get_subscriber_id() should fix this issue.

modelm added a commit to modelm/ConvertKitSDK-PHP that referenced this issue Jul 15, 2021
@duplaja
Copy link

duplaja commented Jul 28, 2021

Just ran into this one myself. I'd pulled the SDK into my project prior to your posting, so didn't see it in open issues, and spent the last couple hours scratching my head. Found the issue, came here to post, and saw your fix. Thank you!

@modelm
Copy link
Author

modelm commented Sep 7, 2021

Here's a workaround until the fix is merged, just make a direct request to /subscribers with the necessary options set instead of using get_subscriber_id():

		$response = $convertkit_client->make_request('v3/subscribers', 'GET', [
			'api_secret' => $api_secret,
			'status' => 'all',
			'email_address' => $user_email,
		]);
		$subscriber = $response->subscribers[0] ?? false;

@mnwalker
Copy link

If it helps anyone you can use this fork https://github.com/mnwalker/convertkitsdk-php

Fixes this issue which also gives a massive performance boost if have many subscribers.
And updated the guzzle version in composer so will work with more modern framework releases.

Have sent @convertkit a pull request but will need someone to merge them.

@mnwalker
Copy link

mnwalker commented Mar 2, 2023

#29

@n7studios
Copy link
Contributor

Fixed in #31. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants