Skip to content

Commit 23586f8

Browse files
committed
Fixed charset setting by refactored httpPost curl sending post body with content type.
Signed-off-by: Kristián Feldsam <[email protected]>
1 parent e051c6e commit 23586f8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Silverpop/EngagePod.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,9 @@ private function _request($data, $replace = array(), $attribs = array()) {
664664
$xml = $data;
665665
}
666666

667-
$fields = array(
668-
"jsessionid" => isset($this->_jsessionid) ? $this->_jsessionid : '',
669-
"xml" => $xml,
670-
);
671-
$response = $this->_httpPost($fields);
667+
$jsessionid = isset($this->_jsessionid) ? $this->_jsessionid : '';
668+
669+
$response = $this->_httpPost($jsessionid, $xml);
672670
if ($response) {
673671
$arr = \Silverpop\Util\xml2array($response);
674672
if (isset($arr["Envelope"]["Body"]["RESULT"]["SUCCESS"])) {
@@ -685,16 +683,18 @@ private function _request($data, $replace = array(), $attribs = array()) {
685683
* Private method: post the request to the url
686684
*
687685
*/
688-
private function _httpPost($fields) {
689-
$fields_string = http_build_query($fields);
686+
private function _httpPost($jsessionid, $xml) {
690687
//open connection
691688
$ch = curl_init();
692689

693690
//set the url, number of POST vars, POST data
694-
curl_setopt($ch,CURLOPT_URL,$this->_getFullUrl());
695-
curl_setopt($ch,CURLOPT_POST,count($fields));
696-
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
691+
curl_setopt($ch,CURLOPT_URL,$this->_getFullUrl().'?jsessionid='.$jsessionid);
692+
curl_setopt($ch,CURLOPT_POSTFIELDS,$xml);
697693
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
694+
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
695+
'Content-Type: text/xml;charset=UTF-8',
696+
'Content-Length: '.strlen($xml)
697+
));
698698

699699
//execute post
700700
$result = curl_exec($ch);

0 commit comments

Comments
 (0)