获取抖音账户的粉丝列表

这个项目分享的如何基于抖音平台,开发的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
 

  • 0
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
获取抖音用户关注列表需要调用抖音API接口,需要使用Python的requests库和抖音API文档。 以下是获取抖音用户关注列表的示例代码: ```python import requests import json # 抖音API接口 url = 'https://api.amemv.com/aweme/v1/user/following/list/' # 设置请求头信息 headers = { 'User-Agent': 'Aweme/2.9.0 (iPhone; iOS 13.5; Scale/2.00)', 'Accept-Encoding': 'gzip, deflate', 'X-SS-TC': '0', 'X-Khronos': '1593474532', 'X-Gorgon': '0404f8c00000c4e3b1c9c61a1d9a3a9e1b7e7f52a8d5e8c5e3de', 'Host': 'api.amemv.com', 'Connection': 'Keep-Alive', 'Cookie': 'odin_tt=4f5d3fbd4e52d1d1fcf6bda4f9b9e8f0d7e8e6e6b7b8b7b7b2b5d5e4f5a8d5e9b1f3e5f3d1d6dce3b8d5e7e5f3d1d6dce3b8d5e7e5f3d1d6dce3b8d5e9b1f3e5f3d1d6dce3b8d5e9b1f3e5f3d1d6dce3b8b7b7b2; install_id=1593471741495; ttreq=1$1b32c7243a6f2f3c4d19b4ce68f92e4d4d9d3b7b; sid_guard=8d0e8d1d2b8f9c8f73a44c88e9e2c7c8%7C1593471755%7C5184000%7CSat%2C+29-Aug-2020+07%3A55%3A55+GMT; uid_tt=9e86f4b7b3e7c2f5eb2f8d4a7a61ab87; sid_tt=8d0e8d1d2b8f9c8f73a44c88e9e2c7c8; sessionid=8d0e8d1d2b8f9c8f73a44c88e9e2c7c8; ss-ticket=ss-ticket=1; device_id=68433556025; openudid=6852c5f94e0edf6a0d5d9dce3fe2d3e2daaa8c61; _ga=GA1.2.1716780489.1593471742; _gid=GA1.2.1482732034.1593471742; _gat_gtag_UA_134238740_1=1; passport_csrf_token_default=07b9bf7c0f4c5c5c7b8a9c1f3f1e8a3f; passport_csrf_token=07b9bf7c0f4c5c5c7b8a9c1f3f1e8a3f; qh[360]=1' } # 请求参数 params = { 'user_id': '123456', # 用户ID,需替换成实际的用户ID 'count': '20', # 返回的关注列表数量 'max_time': '0', # 上一次请求返回的最后一个关注用户的时间戳 'offset': '0' # 偏移量 } # 发送请求 response = requests.get(url, params=params, headers=headers) # 解析响应数据 data = json.loads(response.text) following_list = data.get('followings') # 输出关注列表 for user in following_list: print(user.get('uid'), user.get('nickname')) ``` 需要注意的是,获取抖音用户关注列表需要提供用户ID和Cookie等信息,这些信息可以通过抓包工具获取。同时,抖音API接口可能随时发生变化,需要及时更新代码中的API接口和请求参数。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Softboy_TM

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值