2013-02-04 66 views
3

我是Guzzle的新手,我試圖利用其服務定義。我能夠以這種方式獲得對eBay API的基本調用。創建基於XML API調用的Guzzle服務定義

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

下一步是將其轉換爲服務定義。閱讀文檔,論壇等,我能夠想出這個。

{ 
    "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" 
        } 
       } 
      } 
     } 
    } 
} 

但是這是不正確的。我希望有人能夠幫助完成這個例子以供參考。謝謝!

+0

你設法得到它的工作邁克?我處於類似的情況。 – input

回答

1

這是參數應該如何看:

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

這將是你的命令

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