2015-03-30 75 views
1

我試圖保存用戶郵寄的PHP黑猩猩的紀錄,但我得到這個錯誤,我不明白:訂閱在PHP

的fsockopen():php_network_getaddresses:的getaddrinfo失敗:沒有這樣的主機是已知的。

我使用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); 
    } 

謝謝指點

+0

請檢查這兩個鏈接: - http://stackoverflow.com/questions/8210099/php-php-network-getaddresses-getaddrinfo-failed-no-such-host-is-known。 http://stackoverflow.com/questions/2661546/php-network-getaddresses-getaddrinfo-failed-name-or-service-not-known – 2015-03-30 19:48:12

+0

如果這是您真正的API密鑰,您可能希望將其從代碼示例中刪除,併爲安全,生成一個新的。 – Shervin 2015-03-30 21:03:51

+0

@謝爾文沒有它不是我真正的API密鑰感謝您的建議:) – 2015-03-31 06:34:05

回答

0

如果這是一個真正的API密鑰,你應該肯定禁用API鍵入並生成一個新的,但這實際上有助於回答這個問題。

MailChimp庫使用API​​密鑰的第二部分來確定which datacenter to connect to。在這種情況下,庫會將其解釋爲'fd7',並嘗試連接到fd7.api.mailchimp.com,這不是有效的MailChimp數據中心。

我想從儀表板重新複製API密鑰,並確保最後一部分看起來像'usX',其中X是1-10之間的某個數字。