gpt4 book ai didi

api - 基于 XML API 调用创建 Guzzle 服务定义

转载 作者:可可西里 更新时间:2023-11-01 16:22:05 25 4
gpt4 key购买 nike

我是 Guzzle 的新手,我正在尝试利用其服务定义。我能够像这样工作得到对 eBay API 的基本调用。

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

但这是不正确的。我希望更开明的人可以帮助完成这个例子以供引用。谢谢!

最佳答案

参数应该是这样的:

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

这是你的命令

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

关于api - 基于 XML API 调用创建 Guzzle 服务定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14690593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com