[英]SagePay Server URL Encoding accented characters issue
我正在努力通過cURL發送到SagePay的參數編碼。 根據他們的文檔,所有參數都需要進行URL編碼。 在將參數作為字符串傳遞給SagePay之前,我在參數上使用PHP的urlencode方法。 這是一部分字符串的示例:-
$data = "BillingFirstnames=Jos%C3%A9+Luis&BillingSurname=Test" ...
但是,它無法在SagePay Server網站上正確呈現帶重音符號的“é”:-
Firstname: José
SagePay的文檔指出,您可以將帶重音符號的字符作為帳單名(例如)的一部分,並且該參數應進行URL編碼。
我們的cURL請求看起來像這樣(以防萬一):
// Set the URL
curl_setopt($cs, CURLOPT_URL, $url);
// No headers, please
curl_setopt ($cs, CURLOPT_HEADER, 0);
// It's a POST request
curl_setopt ($cs, CURLOPT_POST, 1);
// Set the fields for the POST
curl_setopt ($cs, CURLOPT_POSTFIELDS, $data);
// Return it direct, don't print it out
curl_setopt($cs, CURLOPT_RETURNTRANSFER,1);
// This connection will timeout in 30 seconds
curl_setopt($cs, CURLOPT_TIMEOUT,30);
curl_setopt($cs, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = preg_split('/$\R?^/m',curl_exec($cs));
關於如何解決此問題的任何建議,以便使名字在SagePay上顯示為“José”?
您可以通過http
標頭設置utf-8
內容類型。 例如:
curl_setopt($cs, CURLOPT_HTTPHEADER,
array('Content-Type: application/x-www-form-urlencoded;charset="utf-8"')
);
您已經在問題中提到了php urlencode
,但是我在您的代碼中沒有看到它。 因此,再次添加。
$post = "age=15&name=".urlencode("José");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.