Update mailchimp-api-php ASAP to fix broken API requests

Created on 12 April 2023, over 1 year ago
Updated 14 October 2023, about 1 year ago

Problem/Motivation

There is a bug in the latest release (rc4) of thinkshout/mailchimp-api-php which cases broken API requests for some api classes (specifically MailchimpApiUser).

Link to github: https://github.com/thinkshout/mailchimp-api-php/pull/115/files

This has been fixed in main but no new release yet.

Steps to reproduce

- Make an API request directly using MailchimpApiUser or a class that inherits from it (like MailchimpReports) using ::request.

EG:

<?php
$mc_reports = mailchimp_get_api_object('MailchimpReports');
$response = $mc_reports->request('GET', '/reports/{campaign_id}/click-details/{link_id}/members', $tokens, $params);

?>

This will result in a 404 exception as the url tokens aren't being replaced correctly.

"404 Resource not found"

Proposed resolution

Update the composer dependency as soon as a new release of the library is available.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

API

Created by

πŸ‡¬πŸ‡§United Kingdom yanniboi UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @yanniboi
  • πŸ‡¬πŸ‡§United Kingdom yanniboi UK
  • I am also having problems after upgrading to 3.0.0-rc4. My code calls MailchimpLists->getSegments(), which gives rise to the error:

    Call to a member function request() on string in Mailchimp\MailchimpLists->getSegments() (line 595 of /home/xxx/yyy/zzz/vendor/thinkshout/mailchimp-api-php/src/MailchimpLists.php)

    MilchimpLists extends MailchimpApiUser, and line 595 is:

    return $this->api_class->request('GET', '/lists/{list_id}/segments', $tokens, $parameters);

    So, it looks like a problem with $this->api_class.
    This might not be the same as the originally reported problem, but I suspect it is related.
    Downgrading back to v2.1.3 fixes the problem.

  • @yanniboi opened merge request.
  • Status changed to Needs review over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom yanniboi UK
  • πŸ‡¬πŸ‡§United Kingdom yanniboi UK

    I am not sure if @dabley's issue is related, however it looks like since mailchimp-api-php has release release candidate 6 with the API fix included we can now update the version dependency of mailchimp module.

  • πŸ‡¨πŸ‡¦Canada sagesolutions

    I am also get this issue when I upgraded to version 2.2.0

    Error: Call to a member function request() on string in Mailchimp\MailchimpLists->getMemberInfo() (line 354 of /var/www/xxx/yyy/vendor/thinkshout/mailchimp-api-php/src/MailchimpLists.php) 
    
  • πŸ‡ΊπŸ‡ΈUnited States bdimaggio Boston, MA

    Just wanted to let folks know we're on this and will address within the week.

  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States aprice42

    Just rolled a new release that includes a fix for this.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed about 1 year ago
  • πŸ‡¨πŸ‡¦Canada sagesolutions

    I tried on the 2.2.2 version and I am still getting the following error

    `Error: Call to a member function request() on string in Mailchimp\MailchimpLists->getMemberInfo()`

    Here is my code snippet below that subscribes a user to a list once they complete the checkout process.

          /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
          $order = $event->getEntity();
          $config = Drupal::config('mailchimp.settings');
          $api_key = $config->get("api_key");
          $mailChimpLists = new MailchimpLists($api_key);
          $listID = '123456789';
          $email = $order->getEmail();
    
          try {
            $member = $mailChimpLists->getMemberInfo($listID, $email);
          }
          catch (Exception $exception) {
    
Production build 0.71.5 2024