Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #119 from mailjet/unescaped_slashes_polyfill
Browse files Browse the repository at this point in the history
json encode slashes for older php version
  • Loading branch information
Guillaume Badi committed Oct 14, 2015
2 parents fe1a66b + 5b8ee29 commit 212763a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Mailjet/php-mailjet-v3-simple.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function requestUrlBuilder($resource, $params = array(), $request, $id)
if ($resource == "sendEmail") {
$this->call_url = $this->apiUrl."/send/message";
}
else if ($resource == "send") {
else if ($resource == "send") {
$this->call_url = $this->apiUrl."/send"; //json support for SendAPI
}
else if ($resource == "uploadCSVContactslistData") {
Expand All @@ -278,7 +278,7 @@ public function requestUrlBuilder($resource, $params = array(), $request, $id)
}
else if (in_array($resource, self::$_templateResources))
{
$this->call_url = $this->makeUrlFromFilter('REST', 'template', $params['ID'], $resource);
$this->call_url = $this->makeUrlFromFilter('REST', 'template', $params['ID'], $resource);
}
else if (in_array($resource, self::$_contactResources))
{
Expand Down Expand Up @@ -407,8 +407,15 @@ public function sendRequest($resource = false, $params = array(), $request = "GE
unset($params['ID']);
}

// 64 => unescaped_slashes
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode($params, 64));
$j_e = null;
if (version_compare(phpversion(), '5.4.0', '<')) {
$j_e = str_replace('\\/', '/', json_encode($params));
} else {
// 64 => unescaped_slashes
$j_e = json_encode($params, 64);
}

curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $j_e);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
Expand Down

0 comments on commit 212763a

Please sign in to comment.