I’m trying to insert a campaign into openX with the XML-RPC API, everything except the start and end dates is working fine, my current code looks like this:
$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');
I’m using the PEAR XML_RPC package. This code runs fine without generating any errors, however when I look at the OpenX control panel my new campaign does not have a start or end date (they are set to “Start Immediatly” and “Don’t Expire”).
What format does the date need to be in, for OpenX to accept it?
EDIT: looked at the http://pear.php.net/package/XML_RPC code, you need to encode your dates as ISO 8601 strings yourself:
Try like this:
(The XML-RPC date type is ‘dateTime.iso8601’, not ‘DateTime’.)