如何使用XMLRPC客户端库设置UTF-8编码


How to set UTF-8 encoding with XMLRPC client library

我使用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

其余的代码是解析$响应,这不是我们这里的主要兴趣。

可以看到,firstName被设置为Čokolada,但是当我在Adestra中检查它时,我得到的值是Äokolada。很明显,编码有问题。

有人能帮忙吗?

在xmlrpc。

$GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';

$GLOBALS['xmlrpc_internalencoding']='UTF-8';