Creating a Guzzle Service Definition Based on an XML API Call

I'm new to Guzzle and I'm trying to take advantage of its service definitions. I was able to get a basic eBay API call that works 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 to a service definition. Reading documents, 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 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 not true. I was hoping that someone more enlightened could help fill out this example for reference. Thank!

+3


source to share


1 answer


This is what the parameters look like:

    "parameters": {
            "RequesterCredentials": {
                "location": "xml",
                "type": "array",
                "items: {
                    "name" = "eBayAuthToken",
                    "type" = "string" 
                }
             }
           }

      



This will be your team

    $command = $client->getCommand("GeteBayOfficialTime", array("RequesterCredentials" => array("AgAAAA**AQAAAA**")));

      

+1


source







All Articles