Skip to content

Fixed charset setting by refactored httpPost curl sending post body w… #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/Silverpop/EngagePod.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,9 @@ private function _request($data, $replace = array(), $attribs = array()) {
$xml = $data;
}

$fields = array(
"jsessionid" => isset($this->_jsessionid) ? $this->_jsessionid : '',
"xml" => $xml,
);
$response = $this->_httpPost($fields);
$jsessionid = isset($this->_jsessionid) ? $this->_jsessionid : '';

$response = $this->_httpPost($jsessionid, $xml);
if ($response) {
$arr = \Silverpop\Util\xml2array($response);
if (isset($arr["Envelope"]["Body"]["RESULT"]["SUCCESS"])) {
Expand All @@ -814,19 +812,19 @@ private function _request($data, $replace = array(), $attribs = array()) {
* Private method: post the request to the url
*
*/
private function _httpPost($fields) {
$fields_string = http_build_query($fields);
private function _httpPost($jsessionid, $xml) {
//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch,CURLOPT_URL,$this->_getFullUrl());
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch,CURLOPT_URL,$this->_getFullUrl().'?jsessionid='.$jsessionid);
curl_setopt($ch,CURLOPT_POSTFIELDS,$xml);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HTTPHEADER,array (
"Content-Type: application/x-www-form-urlencoded; charset=utf-8" ));
curl_setopt($ch,CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml;charset=UTF-8',
'Content-Length: '.strlen($xml)
));

//execute post
$result = curl_exec($ch);
Expand Down