success() public method

Was the last request successful?
public success ( ) : boolean
return boolean True for success, false for failure
コード例 #1
1
ファイル: subscribe.php プロジェクト: arobbins/sblog
<?php

require "../vendor/autoload.php";
use DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp('255970dd153fe7b1d83bec1478cbaa74-us11');
$result = $MailChimp->get('lists');
// Mailing List
// $list_id = '5c6bd183d4';
// Simpleblend Blog
$list_id = '53f4059701';
$result = $MailChimp->post("lists/{$list_id}/members", ['email_address' => '*****@*****.**', 'status' => 'subscribed']);
if ($MailChimp->success()) {
    print_r($result);
} else {
    echo $MailChimp->getLastError();
}
// require_once 'inc/MCAPI.class.php';
// $api = new MCAPI('[[YOUR_API_KEY]]');
// $merge_vars = array('FNAME'=>$_POST["fname"], 'LNAME'=>$_POST["lname"]);
//
// // Submit subscriber data to MailChimp
// // For parameters doc, refer to: http://apidocs.mailchimp.com/api/1.3/listsubscribe.func.php
// $retval = $api->listSubscribe( '[[YOUR_LIST_ID]]', $_POST["email"], $merge_vars, 'html', false, true );
//
// if ($api->errorCode){
//   echo "<h4>Please try again.</h4>";
//
// } else {
//   echo "<h4>Thank you, you have been added to our mailing list.</h4>";
//
// }
コード例 #2
0
 public function import_content(\DrewM\MailChimp\MailChimp $MailChimpAPI)
 {
     // import content
     $campaignID = $this->campaignMailChimpID();
     $content = $MailChimpAPI->get("campaigns/{$campaignID}/content");
     if ($MailChimpAPI->success()) {
         $this->update(['campaignText' => $content['plain_text'], 'campaignHTML' => $content['html']]);
     }
 }
コード例 #3
0
 /**
  * Handles responses from the MailChimp API.
  *
  * @param MailChimp $mailChimp
  * @return Array
  */
 public function handleMailChimpResponse($mailChimp)
 {
     $response = $mailChimp->getLastResponse();
     if (!$mailChimp->success()) {
         $message = $response && array_key_exists($response['errors']) ? $response['errors'][0]['message'] : 'Error connecting to MailChimp API';
         user_error($message, E_USER_ERROR);
     }
     return Convert::json2array($response['body']);
 }
コード例 #4
0
 /**
  * Fetches a list of email templates from MailChimp.
  *
  * @param MailChimp $mailChimp
  * @return ArrayList
  */
 public function getMailChimpTemplates($mailChimp)
 {
     $templates = ArrayList::create();
     $response = $mailChimp->get('templates');
     if (!$mailChimp->success()) {
         $message = $response && array_key_exists($response['errors']) ? $response['errors'][0]['message'] : 'Error connecting to MailChimp API';
         user_error($message, E_USER_ERROR);
     }
     foreach ($response['templates'] as $template) {
         if ($template['type'] == 'user') {
             $templates->push(ArrayData::create($template));
         }
     }
     $this->extend('updateMailChimpTemplates', $templates);
     return $templates;
 }