Mailchimp Api订阅者通过php检查
我想检查一个用户输入的电子邮件地址是否已经在用户列表中。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);
}
?>
这将返回所有电子邮件用户。我试图缩小到用户输入的特定电子邮件,但我卡住了,不知道该怎么做?
回答:
/** 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);
}
?>
以上是 Mailchimp Api订阅者通过php检查 的全部内容, 来源链接: utcz.com/qa/263659.html