2012-09-27 38 views
0

有人可以向我解釋PayPal示例中這些字符串值中「+」和「 - 」的含義嗎? PayPal文檔實際上沒有在API文檔中解釋這一點。PayPal開具API請求 - 格式

&invoice.itemList.item(0).name=Banana+Leaf+--+001 
&invoice.itemList.item(0).description=Banana+Leaf 

我看到一些值是URL編碼等都有這些「+」和「 - 」字符,而不是URL編碼。

爲什麼?

感謝

############################################################ 
// CreateAndSendInvoice HTTP headers (-H) 
############################################################ 
curl -s --insecure 
-H "X-PAYPAL-SECURITY-USERID: caller_UID"  // UserID from the Caller account 
-H "X-PAYPAL-SECURITY-PASSWORD: caller_PSWD" // Password from the Caller account 
-H "X-PAYPAL-SECURITY-SIGNATURE: caller_Sig" // Signature from the Caller account 
-H "X-PAYPAL-REQUEST-DATA-FORMAT: XML" 
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: XML" 
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T" // Sandbox AppID 
https://svcs.sandbox.paypal.com/Invoice/CreateAndSendInvoice -d 
"requestEnvelope.errorLanguage=en_US 
&invoice.merchantEmail=merchant%40domain.com 
&invoice.payerEmail=jbui-us-business2%40paypal.com 
&invoice.currencyCode=USD 
&invoice.itemList.item(0).name=Banana+Leaf+--+001 
&invoice.itemList.item(0).description=Banana+Leaf 
&invoice.itemList.item(0).quantity=1 
&invoice.itemList.item(0).unitPrice=1 
&invoice.itemList.item(0).taxName=Tax1 
&invoice.itemList.item(0).taxRate=10.25 
&invoice.paymentTerms=Net10 
&invoice.logoUrl=https%3A%2F%2Fwww.example.com%2FYour_logo.jpg" 

回答

0

首先,在-符號並不需要進行URL編碼。事實上,如果你看看這個頁面的URL,你會看到https://stackoverflow.com/questions/12626956/paypal-invoicing-api-requests-formatting,其中有大量的-符號。

其次,空格可以由+%20表示,具體取決於它在URL中的位置。從this answer報價:

+ means a space only in application/x-www-form-encoded content, 
such as the query part of a URL: 

http://www.example.com/path/foo+bar/path?query+name=query+value 

In this URL, the parameter name is 'query name' (with a space) and 
the value is 'query value' (with a space), but the folder name in 
the path is literally foo+bar, not 'foo bar'. 
與你的例子

所以,Banana+Leaf+--+001轉化爲Banana Leaf -- 001Banana+Leaf轉化爲Banana Leaf