获取抖音账户的粉丝列表

这个项目分享的如何基于抖音平台,开发的java源码:

API覆盖率超过95%, 只需要简单的修改一下配置文件, 就能轻松调用api.
自动集成官方SDK, 切换使用原生一样方便! 多种选择, 轻松适配!
根据视频大小, 自动切换视频分片上传, 轻松避免异常, 保证接口安全.
接口分类清晰, 操作简单明了
[订阅获取教程全部和source code]
 

获取用户最近的粉丝列表,不保证顺序;目前可查询的粉丝数上限 5 千。该接口适用于抖音。

本接口获取的粉丝数据为抖音的粉丝,抖音客户端展示的还包括头条和西瓜的粉丝数,与抖音端上数据可能不一致。

GET /fans/list/

请求头
Content-Type: application/json
access-token: 调用/oauth/access_token/生成的 token,此 token 需要用户授权。示例: act.1d1021d2aee3d41fee2d2add43456badMFZnrhFhfWotu3Ecuiuka27L56lr

基于文档开发的源码:

package com.douyin.open.api;

import com.douyin.open.ApiClient;

import com.douyin.open.models.UserFollowingFollowingInlineResponse200;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2020-08-13T12:09:25.484473+08:00[Asia/Shanghai]")@Component("com.douyin.open.api.FollowingListApi")
public class FollowingListApi {
    private ApiClient apiClient;

    public FollowingListApi() {
        this(new ApiClient());
    }

    @Autowired
    public FollowingListApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /**
     * 获取关注列表
     * * Scope: `following.list` 
     * <p><b>200</b>
     * @param openId 通过/oauth/access_token/获取,用户唯一标志
     * @param accessToken 调用/oauth/access_token/生成的token,此token需要用户授权。
     * @param count 每页数量
     * @param cursor 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
     * @return UserFollowingFollowingInlineResponse200
     * @throws RestClientException if an error occurs while attempting to invoke the API
     */
    public UserFollowingFollowingInlineResponse200 followingListGet(String openId, String accessToken, Integer count, Long cursor) throws RestClientException {
        Object postBody = null;
        // verify the required parameter 'openId' is set
        if (openId == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'openId' when calling followingListGet");
        }
        // verify the required parameter 'accessToken' is set
        if (accessToken == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'accessToken' when calling followingListGet");
        }
        // verify the required parameter 'count' is set
        if (count == null) {
            throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'count' when calling followingListGet");
        }
        String path = UriComponentsBuilder.fromPath("/following/list/").build().toUriString();
        
        final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
        final HttpHeaders headerParams = new HttpHeaders();
        final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "open_id", openId));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "access_token", accessToken));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "cursor", cursor));
        queryParams.putAll(apiClient.parameterToMultiValueMap(null, "count", count));

        final String[] accepts = { 
            "application/json"
         };
        final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
        final String[] contentTypes = {  };
        final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

        String[] authNames = new String[] {  };

        ParameterizedTypeReference<UserFollowingFollowingInlineResponse200> returnType = new ParameterizedTypeReference<UserFollowingFollowingInlineResponse200>() {};
        return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
    }
}

 

 源码地址:

https://github.com/LovebuildJ/douyin-open-api-sdk
 
 

Guess you like

Origin blog.csdn.net/icemanyandy/article/details/125327375