我正在使用XMLRPC客户端来调用Adestra API服务。目前我在插入波斯尼亚语字母č,ć,ž,đ,š时遇到问题。
我将XMLRPC客户端配置为使用UTF-8,但仍然存在问题。这是我的代码示例:
//******* LOGIN DATA*******/
$account = 'account';
$username = 'username';
$password = 'password';
$adestraCoreTable=1;
/**INITIALIZE API*****/
require_once('xmlrpc.inc');//First inlcude XMLRPC client library
//Calling Adestra API with our credentials
$xmlrpc= new xmlrpc_client("http://$account.$username:$password@new.adestra.com/api/xmlrpc");
$xmlrpc->setDebug(0);
$xmlrpc->request_charset_encoding="UTF-8";
$msg = new xmlrpcmsg(
"contact.search",
array(
//Set user id
new xmlrpcval($adestraCoreTable, "int"),
new xmlrpcval(
array(
"firstName"=> new xmlrpcval("Čokolada", "string"),
),"struct"
)
)
);
$response = $xmlrpc->send($msg);//Send request, and get the response
其余代码正在解析$ response,这不是我们的主要兴趣。
如您所见,firstName
设置为Čokolada
,但当我在Adestra中检查时,我得到值Äokolada
。显然,编码存在问题。
任何人都可以提供帮助吗?
答案 0 :(得分:5)
在xmlrpc.inc中替换此
$GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
用这个
$GLOBALS['xmlrpc_internalencoding']='UTF-8';