put() 공개 메소드

Make an HTTP PUT request - for creating new items
public put ( string $method, array $args = [], integer $timeout = 10 ) : array | false
$method string URL of the API request method
$args array Assoc array of arguments (usually your data)
$timeout integer Timeout limit for request in seconds
리턴 array | false Assoc array of API response, decoded from JSON
예제 #1
0
 public function updateContent($campaignId, $html, $options = [])
 {
     $defaultOptions = compact('html');
     $options = array_merge($defaultOptions, $options);
     $response = $this->mailChimp->put("campaigns/{$campaignId}/content", $options);
     if (!$this->lastActionSucceeded()) {
         return false;
     }
     return $response;
 }
 /**
  * Populates a MailChimp Campaign with Blog content via the API.
  *
  * @param MailChimp $mailChimp
  * @param Int $campaignID
  * @return Array
  */
 public function populateCampaignContent($mailChimp, $campaignID)
 {
     $mailChimp->put("campaigns/{$campaignID}/content", ['template' => ['id' => $this->record->TemplateID, 'sections' => ['chimpify' => $this->record->getCampaignContent()]]]);
     return $this->handleMailChimpResponse($mailChimp);
 }
예제 #3
0
<?php

// load in mailchimp library
include './MailChimp.php';
require_once dirname(__FILE__) . '../../../../wp-config.php';
// namespace defined in MailChimp.php
use DrewM\MailChimp\MailChimp;
// connect to mailchimp
$MailChimp = new MailChimp(get_option('api_key'));
// put your API key here
$list = get_option('list_id');
// put your list ID here
$email = $_GET['EMAIL'];
// Get email address from form
$id = md5(strtolower($email));
// Encrypt the email address
if (get_option('opt_in') == 1) {
    $opt_in = 'pending';
} else {
    $opt_in = 'subscribed';
}
// setup th merge fields
$mergeFields = array();
// remove empty merge fields
$mergeFields = array_filter($mergeFields);
$result = $MailChimp->put("lists/{$list}/members/{$id}", array('email_address' => $email, 'status' => $opt_in, 'update_existing' => true));
echo json_encode($result);