Reputation: 12819
I am new to Guzzle and I am trying to take advantage of its service definitions. I was able to get a basic call to the eBay API working like this.
$request = $client->post('', [
'X-EBAY-API-COMPATIBILITY-LEVEL' => '807',
'X-EBAY-API-DEV-NAME' => 'my-dev-name',
'X-EBAY-API-APP-NAME' => 'my-app-name',
'X-EBAY-API-CERT-NAME' => 'my-cert-name',
'X-EBAY-API-SITEID' => '0',
'X-EBAY-API-CALL-NAME' => 'GeteBayOfficialTime',
],
'<?xml version="1.0" encoding="utf-8"?>
<GeteBayOfficialTimeRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>AgAAAA**AQAAAA**</eBayAuthToken>
</RequesterCredentials>
</GeteBayOfficialTimeRequest>'
);
The next step is to convert this into a service definition. Reading through the docs, forums etc I was able to come up with this.
{
"name": "eBay example",
"apiVersion": "2012-10-14",
"baseUrl": "https://api.sandbox.ebay.com/ws/api.dll",
"description": "it's the eBay API",
"operations": {
"GeteBayOfficialTime": {
"httpMethod": "POST",
"uri": "",
"responseClass": "GeteBayOfficialTime",
"summary": "Gets the official time according to eBay",
"data": {
"xmlRoot": {
"name": "GeteBayOfficialTime"
}
},
"parameters": {
"RequesterCredentials": {
"location": "xml",
"type": "string"
}
}
}
},
"models": {
"GeteBayOfficialTime": {
"type": "array",
"items": {
"type": "object",
"properties": {
"TiemStamp": {
"location": "xml",
"type": "string"
}
}
}
}
}
}
But this is incorrect. I was hoping someone more enlightened can help complete this example for a reference.
Upvotes: 3
Views: 704
Reputation: 11
This is how the parameters should look:
"parameters": {
"RequesterCredentials": {
"location": "xml",
"type": "array",
"items: {
"name" = "eBayAuthToken",
"type" = "string"
}
}
}
This will be your command
$command = $client->getCommand("GeteBayOfficialTime", array("RequesterCredentials" => array("AgAAAA**AQAAAA**")));
Upvotes: 1