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

 wwdd罗曼史 发布于 2023-01-09 08:30

我正在使用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.显然,编码存在问题.

有人可以帮忙吗?

1 个回答
  • 在xmlrpc.inc中替换它

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

    有了这个

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

    2023-01-09 08:37 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有