Skip to content
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

Remove inefficient subscriber paging #29

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions src/ConvertKit_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function get_subscriber_id( $email_address ) {

$options = array(
'api_secret' => $this->api_secret,
'status' => 'all',
'email_address' => $email_address,
);

$this->create_log(sprintf("GET subscriber id from all subscribers: %s, %s, %s", $request, json_encode($options), $email_address));
Expand All @@ -366,27 +366,7 @@ public function get_subscriber_id( $email_address ) {
return $subscriber_id;
}

$total_pages = $subscribers->total_pages;

$this->create_log(sprintf("Total number of pages is %s", $total_pages));

for ( $i = 2; $i <= $total_pages; $i++ ) {
$options['page'] = $i;
$this->create_log(sprintf("Go to page %s", $i));
$subscribers = $this->make_request( $request, 'GET', $options );

if( !$subscribers ) {
return false;
}

$subscriber_id = $this::check_if_subscriber_in_array($email_address, $subscribers->subscribers);

if($subscriber_id) {
return $subscriber_id;
}
}

$this->create_log("Subscriber not found anywhere");
$this->create_log("Subscriber not found");

return false;

Expand Down