【问题标题】:Mailjet How to check email has been subscribed or notMailjet 如何检查电子邮件是否已订阅
【发布时间】:2016-02-11 03:46:09
【问题描述】:

我正在使用 Mailjet 为时事通讯添加订阅者。 如何查看邮箱是否订阅。

我之前使用过下面的方法但是不检查或者返回邮件已经订阅或者不只是更新它并返回响应成功。

这是我的代码:

$mj = new \Mailjet\Client(MJ_APIKEY_PUBLIC, MJ_APIKEY_PRIVATE); // CREATE CONTACT AND SUBSCRIBE AT ONCE // Adding User into Mailjet Contact as Subscriber for Newsletter $body = [ 'Email' => $POST['email'], 'Name' => $POST['name'], 'Action' => "addnoforce", ]; $contactlistID = 3; $response = $mj->post(\Mailjet\Resources::$ContactslistManagecontact, ['id' => $contactlistID, 'body' => $body]); // Read the response if ($response->success()) { $feedback = array('type' => 'success', 'msg' => 'Your email has been registered succesfully.'); }

希望有解决方案,非常感谢。

【问题讨论】:

    标签: php api mailjet


    【解决方案1】:

    回复还包含$response->success 的详细信息,您可以通过以下方式轻松查看:

    $response->getData()
    
    array(1) {
      [0]=>
        array(5) {
          ["ContactID"]=>
            int(1682906939)
          ["Email"]=>
            string(14) "gbadi@test.com"
          ["Action"]=>
            string(10) "addnoforce"
          ["Name"]=>
            string(13) "Test"
          ["Properties"]=>
            array(0) {
            }
         }
       }
    

    如需事后查询,可拨打Resources::$ContactGetcontactslists

    $response = $mailjet->get(Resources::$ContactGetcontactslists, [
      'id' => 'email or id'
    ]);
    
    var_dump($response->getData());
    var_dump($response->success());
    var_dump($response->getStatus());
    

    哪个会返回

    array(1) {
      [0]=>
      array(3) {
        ["IsActive"]=>
        bool(true)
        ["IsUnsub"]=>
        bool(false)
        ["ListID"]=>
        int(1)
      }
    }
    bool(true)
    int(200)
    

    【讨论】:

      猜你喜欢
      • 2014-09-25
      • 2012-08-30
      • 2016-12-06
      • 1970-01-01
      • 2015-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多