开发者

Sending dates with XML-RPC to OpenX

开发者 https://www.devze.com 2023-01-13 17:19 出处:网络
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:

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 m开发者_如何学编程y 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:

$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');

(The XML-RPC date type is 'dateTime.iso8601', not 'DateTime'.)


Have you read this? Changing date format It should be able to tell you how it is set up and then you can either enter it that way or change it to fit your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号