2017-12-18 2 views
-1

ユーザが既に入力した電子メールアドレスが購読者のリストにあるかどうかを確認しようとしています。Mailchimp Api Subscriber 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); 
} 
?> 
関連する問題