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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记