我正在使用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
.显然,编码存在问题.
有人可以帮忙吗?
在xmlrpc.inc中替换它
$GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
有了这个
$GLOBALS['xmlrpc_internalencoding']='UTF-8';