【问题标题】:Mailchimp Api Subscriber Check via phpMailchimp Api 订阅者通过 php 检查
【发布时间】:2018-05-31 20:26:08
【问题描述】:

我正在尝试检查用户输入的电子邮件地址是否已在订阅者列表中。

这是我迄今为止尝试过的:

<?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);
}
?>

这将返回所有电子邮件订阅者。我正在尝试将其缩小到用户输入的特定电子邮件,但我被卡住了,不知道该怎么做?

【问题讨论】:

    标签: php mailchimp-api-v3.0


    【解决方案1】:
    /** 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] == "myemail@gmail.com") { echo "XXXXXXX";} else { }
          }
          $i++;
        }
      }
      fclose($handle);
    }
    ?>
    

    【讨论】:

      猜你喜欢
      • 2016-06-12
      • 2013-08-27
      • 1970-01-01
      • 2019-02-28
      • 2018-02-11
      • 2019-02-17
      • 2019-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多