首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SmartyStreets什么都不起作用

使用SmartyStreets什么都不起作用
EN

Stack Overflow用户
提问于 2020-07-31 02:44:30
回答 1查看 1.3K关注 0票数 3

我正在使用SmartyStreets API来验证纽约市的有效街道地址。我下载了他们的示例代码文件,并尝试使用各种不同的值运行它。我试了一下我的地址,苹果总部的地址,甚至是他们预装的股票地址,都没有用。,这是示例类,它是它们中最短的模板。

代码语言:javascript
复制
public class Example {
public static void main(String[] args) throws IOException, SmartyException {
    // This keypair will have been deleted by the time you are watching this video...
    String authId = "d418a4cc-69da-e48f-bc9d-ee7357b30d61";
    String authToken = "clDiwTlcW5YTFjEl5mp1";

    System.out.println("Step 0. Wire up the client with your keypair.");
    Client client = new ClientBuilder(authId, authToken).buildUsStreetApiClient();

    System.out.println("Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)");
    Lookup lookup = new Lookup();
    lookup.setStreet("1 Rosedale");
    lookup.setLastline("Baltimore MD");
    lookup.setMaxCandidates(10);

    System.out.println("Step 2. Send the lookup.");
    client.send(lookup);

    System.out.println("Step 3. Show the resulting candidate addresses:");
    int index = 0;
    for (Candidate candidate : lookup.getResult()) {
        System.out.printf("- %d: %s, %s\n", index, candidate.getDeliveryLine1(), candidate.getLastLine());
        index++;
    }
}

运行这个主要方法后,我应该得到的消息是:

代码语言:javascript
复制
Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Step 3. Show the resulting candidate addresses:
- 0: 1 N Rosedale St, Baltimore MD 21229-3737
- 1: 1 S Rosedale St, Baltimore MD 21229-3739

,但是我得到了这个和一个错误代码:

代码语言:javascript
复制
Step 0. Wire up the client with your keypair.
Step 1. Make a lookup. (BTW, you can also send entire batches of lookups...)
Step 2. Send the lookup.
Exception in thread "main" com.smartystreets.api.exceptions.BadCredentialsException: Unauthorized: The credentials were provided incorrectly or did not match any existing, active credentials.
    at com.smartystreets.api.StatusCodeSender.send(StatusCodeSender.java:21)
    at com.smartystreets.api.SigningSender.send(SigningSender.java:18)
    at com.smartystreets.api.URLPrefixSender.send(URLPrefixSender.java:19)
    at com.smartystreets.api.RetrySender.trySend(RetrySender.java:34)
    at com.smartystreets.api.RetrySender.send(RetrySender.java:23)
    at com.smartystreets.api.us_street.Client.send(Client.java:48)
    at com.smartystreets.api.us_street.Client.send(Client.java:27)
    at examples.Example.main(Example.java:25)

Process finished with exit code 1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-31 05:30:58

解决方案:我私下收到了解决我的问题的以下解决方案,我认为该解决方案是该程序的开发人员。

转到下面的链接https://account.smartystreets.com/#keys

登录并滚动到页面底部,上面写着自动生成。您必须从这里获取auth id和auth令牌值,并使用它们替换示例类中的虚拟值。

此时,您可以在美国测试任何您想要的地址。有关需要哪些组合和部分地址的裁决,请检查以下链接:https://smartystreets.com/docs/cloud/us-street-api#root

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63185032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档