diff --git a/lib/OAuthSimple.php b/lib/OAuthSimple.php index 00dc4af..614e633 100644 --- a/lib/OAuthSimple.php +++ b/lib/OAuthSimple.php @@ -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 ); @@ -466,4 +471,4 @@ function _generateSignature () { } } } -?> \ No newline at end of file +?> diff --git a/lib/XeroOAuth.php b/lib/XeroOAuth.php index ab6955a..579d5ca 100644 --- a/lib/XeroOAuth.php +++ b/lib/XeroOAuth.php @@ -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 );