TikTok open API video.list Fields request

Can retrieve videos without any problems but trying to request the 'fields' in endpoint always calls a 404 error. I try to follow the documentation https://developers.tiktok.com/doc/login-kit-video-list but maybe i'm attatching '&fields' or 'like_count' incorrectly to the url. Not sure how to structure the request.. any help? Thanks error received

$tik_token = $tik_tok_access;
$tik_open_tk = $tik_open;


$url = 'https://open-api.tiktok.com/video/list/?open_id='.$tik_open_tk.'&access_token='.$tik_token.'&cursor=0&max_count=1&fields=like_count';
$json = file_get_contents($url);
$jo = json_decode($json, true);


var_dump($jo);

1 answer

  • answered 2022-05-04 13:08 Will Levy

    Get method to POST. Called Curl instead.

    https://3v4l.org/NXign

    <?php
    
    $url = 'https://open-api.tiktok.com/video/list/';
    
    $data = '{
        "access_token": "'.$tik_token.'",
        "open_id": "'.$tik_open_tk.'",
        "cursor": 0,
        "max_count": 1,
        "fields": ["embed_html", "embed_link", "share_count"]
    }';
    
    $ch = curl_init($url);                                                                      
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);                                                                  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
    //curl_setopt($ch, CURLOPT_HTTPHEADER, $additional_headers); 
    
    $server_output = curl_exec ($ch);
    
    echo  $server_output;
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum