douxin20081125 2017-03-24 05:32 采纳率: 0%
浏览 72

与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.

  • 写回答

1条回答 默认 最新

  • duanhuanbo5225 2017-03-24 23:27
    关注

    I resolved the issue, I had the wrong API key and data center, their messaging should have been clearer. To avoid this mistake again I've written the following in my config file.

    $config['api_key'] = '1276381263872163872163872-us11';
    $data_center = explode("-", $config['api_key']);
    $config['api_endpoint'] = 'https://'.$data_center[1].'.api.mailchimp.com/3.0/';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog