USPS API 返回 501 未实现

发布于 2024-09-28 19:59:39 字数 932 浏览 1 评论 0原文

我正在尝试利用 USPS API 进行一些地址验证/确认。

我将此 XML 发送到 http://testing.shippingapis.com/ShippingAPITest.dll

<AddressValidateRequest%20USERID="xxxxx"><Address ID="0"><Address1></Address1><Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State><Zip5></Zip5><Zip4></Zip4></Address></AddressValidateRequest>

这与测试请求文档中显示的 XML 相同。但是,我总是收到 HTML(而不是 XML)响应,该响应是 501 Not Implmented 错误。熟悉这个 API 的人知道会发生什么吗? 请求

我正在使用curl(在php中)来发出更新 :当我通过在带有 get params 的浏览器中输入 url 来发出请求时,它似乎工作正常,但我使用 php/curl 或仅从命令行中使用curl 收到上述错误。

更新:如果我使用 file_get_contents 和 url,我会收到 400 bad request 错误 - 但如果我 urlencode,它效果很好 - 解决方案被接受。

I am attempting to utilize the USPS API to do some address verification/validation.

I'm sending this XML to http://testing.shippingapis.com/ShippingAPITest.dll:

<AddressValidateRequest%20USERID="xxxxx"><Address ID="0"><Address1></Address1><Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State><Zip5></Zip5><Zip4></Zip4></Address></AddressValidateRequest>

This is the same XML that is shown in their documentation for test requests. However, I always get an HTML (instead of XML) response that is a 501 Not Implmented error. Anyone familiar with this API know what might be going on? I'm using curl (in php) to make the request

UPDATE: When I make the request by typing the url into a browser with get params, it seems to work fine, but i get the error mentioned above using php/curl or just curl from the command line.

UPDATE: If I use file_get_contents with the url, I get a 400 bad request error - but if i urlencode, it works great - solution accepted.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一张白纸 2024-10-05 19:59:39

不熟悉API,但是:

您需要AddressValidateRequest后面的%20吗?当它被替换为空格时它起作用吗?

另外,需要使用CURL吗?您可以只使用 fopen()file_get_contents() 然后使用您提到的 GET 参数吗?

Not familiar with the API, but:

Do you need the %20 after AddressValidateRequest? Does it work when that is replaced by a space?

Also, do you need to use CURL? Could you just use fopen() or file_get_contents() and then use the GET parameters which you mention work OK?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文