0

有人可以向我解释 PayPal 示例中这些字符串值中“+”和“-”的意义吗?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" 
4

1 回答 1

0

首先,-符号不需要进行 URL 编码。事实上,如果您查看此页面的 URL,您会看到https://stackoverflow.com/questions/12626956/paypal-invoicing-api-requests-formatting其中有很多-符号。

其次,一个空间可以由+或者%20取决于它在 URL 中的位置来表示。引用这个答案

+ 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.

于 2013-08-14T03:01:26.577 回答