Giter Club home page Giter Club logo

doudian-api-java's Introduction

抖音开放平台(v2) Java SDK

快速开始

将项目安装到本地maven,通过坐标引用,最新版本 1.0.1

<dependency>
    <groupId>io.github.xopenapi</groupId>
    <artifactId>doudian</artifactId>
    <version>1.0.1</version>
</dependency>

jdk 要求最低1.8

在Springboot中使用

实例化TiktokOpen类,基本所有操作都通过该类执行,建议注册为单例

@Configuration
public class TiktokConfig {

    private String appKey = "你的应用key";
    private String appSecret = "你的密钥";

    @Bean
    public TiktokOpen tiktokOpen(){
        // 通过config设置基本属性
        TiktokOpenConfig config = new TiktokOpenConfig();
        config.setAppKey(appKey);
        config.setAppsercet(appSecret);
        // 可以设定超时时间等参数
        config.setConnectTimeout(10000);
        
        // err回调 根据抖音错误码 可以进行统一处理
        ErrNoHandleConfig errNoHandle = new ErrNoHandleConfig();
        
        errNoHandle.setAuthorize30006Handle((msg) -> {
            // 回调内容是失效的token
            System.out.println(msg);
        });

        TiktokOpen client = new TiktokOpen(config);
        client.setErrNoHandleConfig(errNoHandle);

        return client;
    }

}

除获取accessToken 与 刷新accessToken外,其他接口调用方法皆为 构造parameter,生成request类,执行并获得response
以获取分类列表为例

@Test
public void productGetCategoryTest() {
    CidParameter cidParameter = new CidParameter(0L);
    ProductGetGoodsCategoryRequest request = new ProductGetGoodsCategoryRequest(cidParameter);
    // accessToken 通过用户授权获得
    ProductGetGoodsCategoryResponse response = client.getTiktokResponse(request, accessToken);
    System.out.println(JSON.toJSONString(response, SerializerFeature.PrettyFormat));
}

doudian-api-java's People

Contributors

okpiaoxuefeng98 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.