我正在尝试使用XML-RPC API将活动插入到openX中,除了开始日期和结束日期之外,其他一切都运行正常,我当前的代码如下所示:
$campaign = new XML_RPC_Value(
array('advertiserId' => new XML_RPC_Value($advertiserID, 'int'),
'campaignName' => new XML_RPC_Value('My Banner', 'string'),
'startDate' => new XML_RPC_Value(new Date(time()), 'DateTime'),
'endDate' => new XML_RPC_Value(new Date(time() + (3600*24*3), 'DateTime')/*3 days into the future*/,
'impressions' => new XML_RPC_Value(10000, 'int'),
'clicks' => new XML_RPC_Value(-1, 'int'),
'priority' => new XML_RPC_Value(1, 'int'),
'weight' => new XML_RPC_Value(0, 'int')
),
'struct');我正在使用PEAR XML_RPC包。这段代码运行良好,不会产生任何错误,但是当我查看OpenX控制面板时,我的新活动没有开始或结束日期(它们被设置为“立即开始”和“不过期”)。
日期需要采用什么格式,OpenX才能接受它?
发布于 2010-09-08 02:57:22
编辑:查看http://pear.php.net/package/XML_RPC代码,您需要自己将日期编码为ISO8601字符串:
试着这样做:
$campaign = new XML_RPC_Value(
array('advertiserId' => new XML_RPC_Value($advertiserID, 'int'),
'campaignName' => new XML_RPC_Value('My Banner', 'string'),
'startDate' => new XML_RPC_Value(date('c'), 'dateTime.iso8601'),
'endDate' => new XML_RPC_Value(date('c', time() + (3600*24*3)), 'dateTime.iso8601')/*3 days into the future*/,
'impressions' => new XML_RPC_Value(10000, 'int'),
'clicks' => new XML_RPC_Value(-1, 'int'),
'priority' => new XML_RPC_Value(1, 'int'),
'weight' => new XML_RPC_Value(0, 'int')
),
'struct');( XML-RPC日期类型是'dateTime.iso8601',而不是‘DateTime’。)
发布于 2010-09-07 17:29:30
你读过这篇文章吗? Changing date format 它应该能够告诉你它是如何设置的,然后你可以用这种方式输入它,或者根据你的需要进行更改。
https://stackoverflow.com/questions/3587891
复制相似问题