public function Mailchimp::request in Mailchimp 8
Makes a request to the Mailchimp API.
Parameters
string $method: The REST method to use when making the request.
string $path: The API path to request.
array $tokens: Associative array of tokens and values to replace in the path.
array $parameters: Associative array of parameters to send in the request body.
bool $batch: TRUE if this request should be added to pending batch operations.
bool $returnAssoc: TRUE to return Mailchimp API response as an associative array.
Return value
mixed Object or Array if $returnAssoc is TRUE.
Throws
92 calls to Mailchimp::request()
- Mailchimp::getAccount in lib/
mailchimp-api-php/ src/ Mailchimp.php - Gets Mailchimp account information for the authenticated account.
- Mailchimp::getBatchOperation in lib/
mailchimp-api-php/ src/ Mailchimp.php - Gets the status of a batch request.
- Mailchimp::processBatchOperations in lib/
mailchimp-api-php/ src/ Mailchimp.php - Processes all pending batch operations.
- MailchimpAutomations::addWorkflowEmailSubscriber in lib/
mailchimp-api-php/ src/ MailchimpAutomations.php - Adds a subscriber to a Mailchimp workflow automation email queue.
- MailchimpAutomations::getAutomations in lib/
mailchimp-api-php/ src/ MailchimpAutomations.php - Gets information about all automations owned by the authenticated account.
File
- lib/
mailchimp-api-php/ src/ Mailchimp.php, line 266
Class
- Mailchimp
- Mailchimp library.
Namespace
MailchimpCode
public function request($method, $path, $tokens = NULL, $parameters = NULL, $batch = FALSE, $returnAssoc = FALSE) {
if (!empty($tokens)) {
foreach ($tokens as $key => $value) {
$path = str_replace('{' . $key . '}', $value, $path);
}
}
if ($batch) {
return $this
->addBatchOperation($method, $path, $parameters);
}
// Set default request options with auth header.
$options = [
'headers' => [
'Authorization' => $this->api_user . ' ' . $this->api_key,
],
];
// Add trigger error header if a debug error code has been set.
if (!empty($this->debug_error_code)) {
$options['headers']['X-Trigger-Error'] = $this->debug_error_code;
}
return $this->client
->handleRequest($method, $this->endpoint . $path, $options, $parameters, $returnAssoc);
}