国外的api之ASANA-java开发-ASANAAPI(真难!)

1.这两个月主要搞了一下国外的协同软件的接入和开发;因为我是新手,所以难度系数MAX++;运用到的难点主要还是接口问题/线程池的问题;

2.简单写一下接入asana接口需要的东西,给大家排一下坑! 语言用的是java;用的spring+Mybatis ;接口工具用的是postman;

  1. -1.导入jar包;(这个比较坑,可能我认知少,我之前用的所有的jar包啥的用的都是国内的例如阿里的啥的,当然因为asana的api是国外的所以是谷歌的,而且我这边可能是我的maven有问题,反正不能自动注入jar包,一个一个jar包放入可太难了QAQ)

    -1.1 导入的jar包有:google-http-client / google-http-client-gson / google-oauth-client / opencensus-api / opencensus-contrib-http-util /grpc-context/httpcore 好像是这些;

    -1.2 meven 贴在下面了:
    `

    <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client</artifactId>
        <version>1.20.0</version>
    </dependency>
    
<!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-gson -->
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-gson</artifactId>
    <version>1.20.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.oauth-client/google-oauth-client -->
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client</artifactId>
    <version>1.20.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.opencensus/opencensus-api -->
<dependency>
    <groupId>io.opencensus</groupId>
    <artifactId>opencensus-api</artifactId>
    <version>0.25.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.opencensus/opencensus-contrib-http-util -->
<dependency>
    <groupId>io.opencensus</groupId>
    <artifactId>opencensus-contrib-http-util</artifactId>
    <version>0.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.grpc/grpc-context -->
<dependency>
    <groupId>io.grpc</groupId>
    <artifactId>grpc-context</artifactId>
    <version>1.27.0</version>
</dependency>

<dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
        <scope>test</scope>
    </dependency>
<!-- https://mvnrepository.com/artifact/org.wso2.apache.httpcomponents/httpclient -->
    <dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.5</version>
    </dependency>`
  1. -2.导入一些需要的实体类/方法;(这个在gethub上找的);

  如备注5;

  1. -3.调用接口;

    -3.1 :获取token- 前提在asana中生成一个app,然后获取它的Client_ID/Client_secret/Redirect_uri(自己域名的路径)

    OAuthApp app = new OAuthApp(AsanaConfig.Client_ID, AsanaConfig.Client_secret, AsanaConfig.Redirect_uri); String state = ShiroUtil.getUser().getUser().getId().toString(); String url = app.getAuthorizationUrl(state);

 OAuthApp a = new OAuthApp(AsanaConfig.Client_ID, AsanaConfig.Client_secret,AsanaConfig.Redirect_uri); token = a.fetchToken(request.getParameter("code"));

-3.2:获取个人信息;

  OAuthApp a = new OAuthApp(AsanaConfig.Client_ID, AsanaConfig.Client_secret, AsanaConfig.Redirect_uri, token); Client client = Client.oauth(a); User me = client.users.me().execute();

4。 坑-获取任务详情中获取不到子任务数量;api上可以找到,但是真的没有;

   坑-webhook(自动推送)只能推送至project,太坑了!!
  1. gethub地址: https://github.com/Asana/java-asana/tree/master/src/main/java/com/asana

    asanaAPI: https://developers.asana.com/docs

  2. 总结:现在看来还是很简单的-难点是前面jar包引入和实体类的导入,方法摆在上面了。。。以上方法可以使用asana接口了,至于其他的关于啥webhook的,这就涉及公司项目了;

  3. 还有不懂问。。(有偿,我真不是

原文地址:https://www.cnblogs.com/alukaa/p/13036828.html