【问题标题】:subscribe on mailchimp in php在 php 中订阅 mailchimp
【发布时间】:2015-03-30 19:41:29
【问题描述】:

我试图将订阅者的记录保存到 php 中的邮件黑猩猩,但我收到了这个我不明白的错误:

fsockopen(): php_network_getaddresses: getaddrinfo failed: No such host is known.

我正在使用 MCAPI 类版本 1.3

这是我要保存的代码:

    $apikey='d9750fc48519551e22e789c1gthy050a5-fd7'; // Enter your API key
    $api = new MCAPI($apikey);
    $retval = $api->lists();


    $listid='d395e7afr4'; // Enter list Id here

    $fname = $this->stepdata['yourName'];
    $lname = $this->stepdata['yourName'];
    $email = $this->stepdata['yourEmail'];


    // By default this sends a confirmation email - you will not see new          members
    // until the link contained in it is clicked!

    $merge_vars = array('FNAME' => $fname, 'LNAME' => $lname, 'EMAIL' => $email);
    //listSubscribe'=>array("id","email_address","merge_vars","email_type","double_optin","update_existing","replace_interests","send_welcome")
    if($api->listSubscribe($listid, $email, $merge_vars, $email_type='html', $double_optin=false, $update_existing=false, $replace_interests=false, $send_welcome=true ) === true) {

    }

这是错误指向 MCAPI 类的地方

   ob_start();
    if ($this->secure){
        $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
    } else {
        $sock = fsockopen($host, 80, $errno, $errstr, 30);
    }

谢谢

【问题讨论】:

标签: php mailchimp


【解决方案1】:

如果这是一个真正的 API 密钥,您绝对应该禁用该 API 密钥并生成一个新的,但这实际上有助于在这种情况下回答这个问题。

MailChimp 库使用 API 密钥的第二部分来确定 which datacenter to connect to。在这种情况下,库会将其解释为“fd7”,并将尝试连接到 fd7.api.mailchimp.com,这不是有效的 MailChimp 数据中心。

我会从您的仪表板重新复制您的 API 密钥,并确保最后一部分看起来像“usX”,其中 X 是 1-10 之间的某个数字。

【讨论】:

    猜你喜欢
    • 2014-07-12
    • 2013-08-27
    • 2015-06-18
    • 2016-07-01
    • 2014-02-19
    • 2012-09-29
    • 2013-11-09
    • 2015-08-13
    • 2015-06-02
    相关资源
    最近更新 更多