Skip to content

Commit b04fa5f

Browse files
authored
Merge pull request #218 from slavielle/master
fix Issue #148 : Mailchimp API - language setting/argument
2 parents 5121e2e + 3e33f96 commit b04fa5f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/MailChimp.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,19 @@ private function makeRequest($http_verb, $method, $args = array(), $timeout = se
196196

197197
$response = $this->prepareStateForRequest($http_verb, $method, $url, $timeout);
198198

199-
$ch = curl_init();
200-
curl_setopt($ch, CURLOPT_URL, $url);
201-
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
199+
$httpHeader = array(
202200
'Accept: application/vnd.api+json',
203201
'Content-Type: application/vnd.api+json',
204202
'Authorization: apikey ' . $this->api_key
205-
));
203+
);
204+
205+
if (isset($args["language"])) {
206+
$httpHeader[] = "Accept-Language: " . $args["language"];
207+
}
208+
209+
$ch = curl_init();
210+
curl_setopt($ch, CURLOPT_URL, $url);
211+
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
206212
curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)');
207213
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
208214
curl_setopt($ch, CURLOPT_VERBOSE, true);

0 commit comments

Comments
 (0)