与CodeIgniter一起使用MailChimp API时出现404错误

I'm trying to integrate MailChimp API. I've switched out two different libraries and getting the same error.

[type] => http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/
[title] => Resource Not Found
[status] => 404
[detail] => The requested resource could not be found.
[instance] => 

Unfortunately this error doesn't provide me any usable information. The library I'm using is this one.

Here's the code I'm using in my controller:

function __construct(){
    parent::__construct(); 

    $this->load->library('mailchimp');
    $this->common = array(
        'list_id'   =>  '12345678',
    );
}

public function signup() {      

    $form = $this->input->post();

    if ( !empty($form['website']) ) {

        // If Honey Pot is filled out
        redirect('https://www.google.com');

    } else {

        $result = $this->mailchimp->call('POST', 
            'lists/'.$this->common['list_id'].'/members', 
            array(
                'email_address' =>  $form['email'], 
                'merge_fields'  =>  array( 
                        "FNAME" =>  $form['first_name'], 
                        "LNAME" =>  $form['last_name'] 
                    ), 
                'status'        =>  'subscribed',
            )
        );

        debug($result);
        return true;

        // Check Result
        if ( $result['status'] !== 'subscribed' && $result['status'] !== 'pending' ) {

            return false;

        } else {

            return true;

        }

    }       
}

The debug function is a helper I have that does a print_r wrapped in <pre> to make my life easier.

I'm hoping this is just a case of staring at the screen too long and missing the obvious or there's something amiss with the MailChimp API.

查看全部
douxin20081125
douxin20081125
2017/03/24 05:32
  • codeigniter
  • php
  • 点赞
  • 收藏
  • 回答
    私信

1个回复