Skip to content
This repository was archived by the owner on Nov 21, 2019. It is now read-only.

Fix issue with PDF attachments #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions lib/OAuthSimple.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,15 @@ function sign($args=array()) {
$this->setParameters($args['parameters']);
$normParams = $this->_normalizedParameters();
$this->_parameters['oauth_signature'] = $this->_generateSignature($normParams);
if (strpos($this->_path,'?') !== false) {
$returnURL = $this->_path . '&' . $this->_normalizedParameters('true');
} else {
$returnURL = $this->_path . '?' . $this->_normalizedParameters('true');
}
return Array(
'parameters' => $this->_parameters,
'signature' => $this->_oauthEscape($this->_parameters['oauth_signature']),
'signed_url' => $this->_path . '?' . $this->_normalizedParameters('true'),
'signed_url' => $returnURL,
'header' => $this->getHeaderString(),
'sbs'=> $this->sbs
);
Expand Down Expand Up @@ -466,4 +471,4 @@ function _generateSignature () {
}
}
}
?>
?>
23 changes: 17 additions & 6 deletions lib/XeroOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,23 @@ private function curlit() {
break;
case 'PUT' :
$fh = tmpfile();
if ($this->format == "file") {
$put_body = $this->xml;
} else {
$put_body = $this->safe_encode ( $this->xml );
$this->headers ['Content-Type'] = 'application/x-www-form-urlencoded';
}
switch ($this->format) {
case "file" :
$put_body = $this->xml;
break;
case "pdf" :
$put_body = $this->xml;
$this->headers ['Content-Type'] = 'application/pdf';
break;
case "json" :
$put_body = $this->xml;
$this->headers ['Content-Type'] = 'application/json';
break;
default :
$put_body = $this->safe_encode ( $this->xml );
$this->headers ['Content-Type'] = 'application/x-www-form-urlencoded';
break;
}
fwrite ( $fh, $put_body );
rewind ( $fh );
curl_setopt ( $c, CURLOPT_PUT, true );
Expand Down