只是我有一个在USPS注册,提供US Address Validation API
. 我正在使用以下代码来获取XML Response
.
但是,不幸的是,Response
说:
授权失败用户 'xxxxxxxxx' 未被授权使用 API Verify.USPSCOM::DoAuth。
我错过了什么吗?
代码:
void IsValidAddress()
{
string USPS = "http://production.shippingapis.com/ShippingAPITest.dll?API=Verify&XML=<AddressValidateRequest%20USERID='xxxxxxx'><Address ID='1'><Address1></Address1><Address2>8 Wildwood Drive</Address2><City>Old Lyme</City><State>CT</State><Zip5>06371</Zip5><Zip4></Zip4></Address></AddressValidateRequest>";
WebClient wsClient = new WebClient();
byte[] responseData = wsClient.DownloadData(USPS);
string response = string.Empty;
foreach (byte item in responseData)
{
//this will return the xml response
response += (char)item;
}
string result = response;
Response.Write(result);
}
请参阅:如何在 USPS 上验证地址
注意:这User ID
是我的个人用户 ID,由 USPS 服务提供商签发。