question

crearevalorespa avatar image
0 Likes"
crearevalorespa asked ·

getOrders datetime error,getOrders datetime error. Got string instead datetime

Hello, I'm newbe into ebay api development. I'm trying a php library ( https://github.com/davidtsadler/ebay-sdk) to retrieve order from my account. Using NumberOfDays everything is fine but if I try to get orders between date range I get Fatal error: Uncaught exception 'DTS\eBaySDK\Exceptions\InvalidPropertyTypeException' with message 'Invalid property type: DTS\eBaySDK\Trading\Types\GetOrdersRequestType::CreateTimeFrom expected , got I understood the problem is with datetime. What I've tried: $creatoda = new DateTime('22-04-2015'); $CreateTimeFrom = $creatoda->format('Y-m-d H:i:s'); $creaofino = new DateTime('22-07-2015'); $CreateTimeTo = $creaofino->format('Y-m-d H:i:s'); This doesn't works. After that checking here http://developer.ebay.com/devzone/xml/docs/reference/ebay/types/simpleTypes.html#dateTime I found a Zulu example **2004-08-04T19:09:02.768Z** So I tried with date("Y-m-d")."T".date("H:i:s.Z")."Z"; or with gmDate("Y-m-d\TH:i:s\Z"); Unfortunately always error. Could someone help me to understand what's I'm doing wrong? Thanks ,Hello, I'm newbe into ebay api development. I'm trying a php library ( https://github.com/davidtsadler/ebay-sdk) to retrieve order from my account. Using NumberOfDays everything is fine but if I try to get orders between date range I get Fatal error: Uncaught exception 'DTS\eBaySDK\Exceptions\InvalidPropertyTypeException' with message 'Invalid property type: DTS\eBaySDK\Trading\Types\GetOrdersRequestType::CreateTimeFrom expected , got I understood the problem is with datetime. What I've tried: $creatoda = new DateTime('22-04-2015'); $CreateTimeFrom = $creatoda->format('Y-m-d H:i:s'); $creaofino = new DateTime('22-07-2015'); $CreateTimeTo = $creaofino->format('Y-m-d H:i:s'); This doesn't works. After that checking here http://developer.ebay.com/devzone/xml/docs/reference/ebay/types/simpleTypes.html#dateTime I found a Zulu example **2004-08-04T19:09:02.768Z** So I tried with date("Y-m-d")."T".date("H:i:s.Z")."Z"; or with gmDate("Y-m-d\TH:i:s\Z"); Unfortunately always error. Could someone help me to understand what's I'm doing wrong? Thanks
apigetordersgetorders-ebay-apidatetime
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
davidtsadler avatar image
0 Likes"
davidtsadler answered ·
The [CreateTimeFrom]( http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetOrders.html#Request.CreateTimeFrom) field is of the [dateTime]( http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/types/simpleTypes.html#dateTime) type. These types are handled in the [SDK]( https://github.com/davidtsadler/ebay-sdk-php) by passing instances of the PHP [DateTime]( http://php.net/manual/en/class.datetime.php) class. You just need to edit your code as follows. $request->CreateTimeFrom = new DateTime('22-04-2015'); $request->CreateTimeTo = new DateTime('22-07-2015'); The SDK will automatically convert the dates into the ISO 8601 string format when sending the request.
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.