Lor*_*mly 5 php xml-rpc type-conversion openx
在使用OpenX API和XML-RPC2进行连接编码时,我遇到了麻烦.我遇到的问题是fire函数需要的数据类型是dateTime.iso8601.
这是我的代码:
$sdatetime = new DateTime('2013-01-01 00:00:00');
$edatetime = new DateTime('2013-06-01 00:00:00');
$startDate = $sdatetime->format(DateTime::ISO8601);
$endDate = $edatetime->format(DateTime::ISO8601);
try {
$result = $aClient->agencyPublisherStatistics($sessionId, 1, $startDate, $endDate);
print_r($result);
} catch (XML_RPC2_FaultException $e) {
die('Exception #' . $e->getFaultCode() . ' : ' . $e->getFaultString());
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的脚本时,这是结果错误:
异常#3:传递给方法的参数不正确:通缉dateTime.iso8601,在参数3处得到了字符串
如果我运行print_r(gettype($startDate));我得到的类型数据是字符串而不是日期.
我的问题,对于变量$startDate以及$endDate如何使他们的数据类型成为dateTime.iso8601或date不是string.
谢谢.
看起来您的 AgencyPublisherStatistics 需要特定的 XML_RPC2_Value 日期对象。您可以通过使用来创建它。
\n\n$startDate = XML_RPC2_Value::createFromNative($startDate, \xe2\x80\x98datetime\xe2\x80\x99);\nRun Code Online (Sandbox Code Playgroud)\n\n结束日期相同..让我知道这是否有效..
\n