2017-12-18 11 views
-1

사용자가 이미 입력 한 전자 메일 주소가 구독자 목록에 있는지 여부를 확인하려고합니다.Mailchimp Api 가입자 php로 확인

이것은 내가 지금까지 시도한 것입니다 :

<?php 
$apikey = 'apikey'; 
$list_id = 'listid'; 
$chunk_size = 4096; //in bytes 
$url = 'http://us14.api.mailchimp.com/export/1.0/list?apikey='.$apikey.'&id='.$list_id; 

/** a more robust client can be built using fsockopen **/ 
$handle = @fopen($url,'r'); 
if (!$handle) { 
    echo "failed to access url\n"; 
} else { 
    $i = 0; 
    $header = array(); 
    while (!feof($handle)) { 
    $buffer = fgets($handle, $chunk_size); 
    if (trim($buffer)!=''){ 
     $obj = json_decode($buffer); 
     if ($i==0){ 
     //store the header row 
     $header = $obj; 
     } else { 
     //echo, write to a file, queue a job, etc. 
     echo $obj[0]; 
     } 
     $i++; 
    } 
    } 
    fclose($handle); 
} 
?> 

이 모든 이메일 가입자를 반환합니다. 사용자가 입력 한 특정 전자 메일까지 범위를 좁히려 고 노력하고 있지만 막혔는데 어떻게해야할지 모르십니까?

답변

0
/** a more robust client can be built using fsockopen **/ 
$handle = @fopen($url,'r'); 
if (!$handle) { 
    echo "failed to access url\n"; 
} else { 
    $i = 0; 
    $header = array(); 
    while (!feof($handle)) { 
    $buffer = fgets($handle, $chunk_size); 
    if (trim($buffer)!=''){ 
     $obj = json_decode($buffer); 
     if ($i==0){ 
     //store the header row 
     $header = $obj; 
     } else { 
     //echo, write to a file, queue a job, etc. 
     if ($obj[0] == "[email protected]") { echo "XXXXXXX";} else { } 
     } 
     $i++; 
    } 
    } 
    fclose($handle); 
} 
?>