Skip to content

Instantly share code, notes, and snippets.

@lumaaaaaa
Created May 14, 2024 19:07
Show Gist options
  • Save lumaaaaaa/29fcf89c20e9a66eb8668121f084e59a to your computer and use it in GitHub Desktop.
Save lumaaaaaa/29fcf89c20e9a66eb8668121f084e59a to your computer and use it in GitHub Desktop.
/*
* Fetches video info from TikTok mobile API given a list of video ids. Returns the response body.
*/
func get_video_info(video_ids []string) string {
client := &http.Client{}
// parse the video ids into the payload
payload := "aweme_ids=%5B" + strings.Join(video_ids, ",") + "%5D"
// fetch video info
req, _ := http.NewRequest("POST", "https://api16-normal-useast5.tiktokv.us/aweme/v1/multi/aweme/detail/?iid=7367114518340306730&device_id=7367114349578602027&channel=googleplay&app_name=musical_ly&version_code=340505&device_platform=android&device_type=WayDroid+x86_64+Deviceen&os_version=11", strings.NewReader(payload))
req.Header.Set("Host", "api16-normal-useast5.tiktokv.us")
req.Header.Set("User-Agent", "com.zhiliaoapp.musically/2023405050 (Linux; U; Android 11; en_US; WayDroid x86_64 Device; Build/RQ3A.211001.001;tt-ok/3.12.13.4-tiktok)")
req.Header.Set("X-Ladon", "Q8FNeH+o3Lj8Pn2UO/gaUAh7puTFMZw/qTG+cgUw7F0VvD6y") // signature header, unenforced (!)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
// send the request
resp, err := client.Do(req)
if err != nil {
fmt.Println("error fetching video info")
return ""
}
// read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("error reading response body")
return ""
}
// return the response body as a string
return string(body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment