'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);
Solution 1:[1]
Get method to POST. Called Curl instead.
<?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;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | karel |
