Giter Site home page Giter Site logo

tiktok-signature's Introduction

NPM npm

Installation

npm i tiktok-signature

Buy Me A Coffee

Usage

Generating signatures on high performance level

Build

docker build . -t tiktok-signature

Run

docker run -p 80:8080 -v $(pwd):/usr/app tiktok-signature

Example

Request signature
curl -X POST \
     -H "Content-type: application/json" \
     -d 'https://m.tiktok.com/share/item/list?secUid=&id=&type=5&count=30&minCursor=0&maxCursor=0&shareUid=' \
     http://localhost/signature

To generate signatures dynamically this repo comes with an integrated http server (listen.js) which accepts POST requests to http://localhost/signature with url in request body.

You have to start the server

npm start

Module

const Signer = require("tiktok-signature"); // Import package

const signer = new Signer(); // Create new signer
await signer.init(); // Create page with. Returns promise

const signature = await signer.sign("tiktok url"); // Get sign for your url. Returns promise
const navigator = await signer.navigator(); // Retrieve navigator data used when signature was generated

console.log(signature);
console.log(navigator);

await signer.close(); // Close browser. Returns promise

You can pass your desired User-Agent on class creation.

new Signer("Mozilla"); // Set User-Agent to Mozilla

CLI

Install dependencies

npm i playwright-chromium

Now you can generate the token using

node browser.js "https://m.tiktok.com/api/post/item_list/?aid=1988&count=30&secUid=MS4wLjABAAAAOUoQXeHglWcq4ca3MwlckxqAe-RIKQ1zlH9NkQkbLAT_h1_6SDc4zyPdAcVdTWZF&cursor=0"

The response token should look like this

{
  "status": "ok",
  "data": {
    "signature": "_02B4Z6wo00f01DBbvBwAAIBCcuSZt1Pua8AwS7iAAGyZ6e",
    "verify_fp": "verify_knvz9j2k_miXwiqOy_msam_42g2_BYoa_e4EAbuQnDwqI",
    "signed_url": "https://m.tiktok.com/api/post/item_list/?aid=1988&count=30&secUid=MS4wLjABAAAAOUoQXeHglWcq4ca3MwlckxqAe-RIKQ1zlH9NkQkbLAT_h1_6SDc4zyPdAcVdTWZF&cursor=0&verifyFp=verify_knvz9j2k_miXwiqOy_msam_42g2_BYoa_e4EAbuQnDwqI&_signature=_02B4Z6wo00f01DBbvBwAAIBCcuSZt1Pua8AwS7iAAGyZ6e&X-Bogus=1BLhm+0j/AG2Dlsz3v4u4w==",
    "x-tt-params": "1BLhm+0j/AG2Dlsz3v4u4w==",
    "x-bogus": "1BLhm+0j/AG2Dlsz3v4u4w==",
    "navigator": {
      "width": 884,
      "height": 1244,
      "deviceScaleFactor": 3,
      "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Windows NT 10.0; Win64; x64) Chrome/90.0.4430.85 Safari/537.36",
      "browser_language": "en-US",
      "browser_platform": "MacIntel",
      "browser_name": "Mozilla",
      "browser_version": "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (Windows NT 10.0; Win64; x64) Chrome/90.0.4430.85 Safari/537.36"
    }
  }
}

Testing

You can test it using trending.py file included in this repo.

pip install Naked
python examples/trending.py

NOTE

It's very important that the userAgent be the same when generate and when request for response.

Keeping a process too much time opened can increase memory usage, to avoid this uncomment the following lines in listen.js.

// setTimeout(function () {
//   server.close(() => {
//     console.log("Server shutdown completed.");
//     process.exit(1);
//   });
// }, 1 * 60 * 60 * 1000);

Buy Me A Coffee

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/carcabot/tiktok-signature.

  1. Fork it (https://github.com/carcabot/tiktok-signature/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some new feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

The lib is available as open source under the terms of the MIT License.

tiktok-signature's People

Contributors

acrogenesis avatar carcabot avatar daviddanielarch avatar emiliobarradas avatar fojia avatar horrrors avatar mvillalba avatar pablouser1 avatar pdenis avatar pthieu avatar stevezheng avatar truecarry avatar yoavz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiktok-signature's Issues

likes and subscribe signature?

Hello, i want like and subscribe in web version tiktok.... How generate signature?
What will the service url for likes look like?
What will the service url for subscribe look like?

UnhandledPromiseRejectionWarning

I'm getting this error when running the listen.js file

TikTok Signature server started (node:4574) UnhandledPromiseRejectionWarning: Error: Protocol error (Playwright.createContext): Browser has been closed. at /home/user/tiktok1/node_modules/playwright-core/lib/webkit/wkConnection.js:102:63 at new Promise (<anonymous>) at WKSession.send (/home/user/tiktok1/node_modules/playwright-core/lib/webkit/wkConnection.js:101:16) at WKBrowser.newContext (/home/user/tiktok1/node_modules/playwright-core/lib/webkit/wkBrowser.js:65:65) at WKBrowser.<anonymous> (/home/user/tiktok1/node_modules/playwright-core/lib/helper.js:64:31) at Signer.init (/home/user/tiktok1/tiktok-signature/index.js:48:39) (node:4574) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:4574) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Json Output

is it possible to host this script on Heroku or google App engine?. Also it would be nice to have it return a json output like a proper api call.

Am an Android / Ios Dev and am not too familiar with backend technology
Great library btw

Can not create signature to get list video of user

I'm trying to get list video of this user https://www.tiktok.com/@kannan17847/
i use like this to get signature

node browser.js "//www.tiktok.com/share/item/list?secUid=MS4wLjABAAAAz15wmO-nnCQp04UPEx2m7Yv0_-fJpBaXsk-uUNTsWTZGQa9NiYmAUpYJdAgbXhbF&id=6715464877845447682&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang="

> s0Ju9AAgEBCwzpufd4fScLNCb-AAO0V
but when run, i can not get data

https://www.tiktok.com/share/item/list?secUid=MS4wLjABAAAAz15wmO-nnCQp04UPEx2m7Yv0_-fJpBaXsk-uUNTsWTZGQa9NiYmAUpYJdAgbXhbF&id=6715464877845447682&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&_signature=s0Ju9AAgEBCwzpufd4fScLNCb-AAO0V

And api still working with true signature

https://www.tiktok.com/share/item/list?secUid=MS4wLjABAAAAz15wmO-nnCQp04UPEx2m7Yv0_-fJpBaXsk-uUNTsWTZGQa9NiYmAUpYJdAgbXhbF&id=6715464877845447682&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&_signature=SpOS3AAgEBSmr-nu7y6.OUqTk8AABTL

TimeOut Browser.js

Hi,
on my local server, it works well but in production, it goes in timeout.
Can my server's IP be banned? How I can test it?

Thank you!
I receive this error message:

node node_modules/tiktok-signature/browser.js "https://m.tiktok.com/api/item_list/?count=20&id=6751746612202537990&type=1&maxCursor=0&minCursor=0&sourceType=8&appId=1233&region=IT&language=it&verifyFp="
TimeoutError: Navigation timeout of 30000 ms exceeded
    at /home/forge/###/node_modules/puppeteer/lib/LifecycleWatcher.js:100:111
  -- ASYNC --
    at Frame.<anonymous> (/home/forge/###/node_modules/puppeteer/lib/helper.js:94:19)
    at Page.goto (/home/forge/###/node_modules/puppeteer/lib/Page.js:476:53)
    at Page.<anonymous> (/home/forge/###/node_modules/puppeteer/lib/helper.js:95:27)
    at Signer.init (/home/forge/###/node_modules/tiktok-signature/index.js:63:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async main (/home/forge/###/node_modules/tiktok-signature/browser.js:8:9)

ReferenceError: generateSignature is not defined

When I require on my project the Signer like -> const Signer = require('tiktok-signature') I keep getting the error "ReferenceError: generateSignature is not defined"...

i'm doing this:

const express = require('express');
const app = express();
const axios = require('axios');
const PORT = 8080;

const Signer = require('tiktok-signature');

app.get('/', async (req, res) => {
const signer = new Signer("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36");
await signer.init();
const token = await signer.sign("https://m.tiktok.com/share/item/list?secUid=&id=xxxxxxxx&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&lang=");
await signer.close();
res.send(token);
});

app.listen(process.env.PORT || PORT, () => {
console.log('Server is running on port:', PORT);
})

please help, maybe i'm doing something wrong

Problem running node server.js on a Raspberry Pi 3 B+

After updating and installing node:

pi@chaengpi:~/scripts/tiktok-signature $ node -v
v10.19.0

I run into a problem when I try running the server.js script.

pi@chaengpi:~/scripts/tiktok-signature $ node server.js 
/home/pi/scripts/tiktok-signature/index.js:9
  userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36";
            ^

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/pi/scripts/tiktok-signature/server.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

I'm not getting much wiser from this error, do you perhaps know why it's causing this issue?

Signature for hashtag videos list

Hello! Can't generate true signature for getting videos bu hashtag.

Getting this url with signature, generated for it, returns empty page:
https://m.tiktok.com/share/item/list?secUid=&id={hashtag id here}&type=3&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyFp=

Signature token is not working

It was working till February 12th.But today when I tried it its not working.Even the trending.py script is not working.Its just returning {'statusCode': 200, 'contentType': 'application/json', 'content': ''}

always the same key

Hello,

When i try to generate a signature, i have always the same key: "s0Ju9AAgEBDs0t-zd4dzFLNCb-AAO0V"

Do you have some information on how it works.

Thanks a lot.

How long can server.js listen continuously?

I had it running overnight, but after about ~12-14 hours of listening non-stop, I suspect it started generating incorrect keys?

Is something like this possible?

Reason that I'm asking this is because after restarting the local server I was getting data again.

Error: Evaluation failed: No function found

Hi,

It looks like TikTok changed something again because it was working fine, but now gives the following error:

tiktoksignature_1  | TikTok Signature server started
tiktoksignature_1  | (node:1) UnhandledPromiseRejectionWarning: Error: Evaluation failed: No function found
tiktoksignature_1  |     at ExecutionContext._evaluateInternal (/usr/src/app/node_modules/puppeteer/lib/ExecutionContext.js:122:13)
tiktoksignature_1  |     at processTicksAndRejections (internal/process/task_queues.js:97:5)
tiktoksignature_1  |     at async ExecutionContext.evaluate (/usr/src/app/node_modules/puppeteer/lib/ExecutionContext.js:48:12)
tiktoksignature_1  |     at async Signer.init (/usr/src/app/index.js:71:5)
tiktoksignature_1  |   -- ASYNC --
tiktoksignature_1  |     at ExecutionContext.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:111:15)
tiktoksignature_1  |     at DOMWorld.evaluate (/usr/src/app/node_modules/puppeteer/lib/DOMWorld.js:112:20)
tiktoksignature_1  |     at processTicksAndRejections (internal/process/task_queues.js:97:5)
tiktoksignature_1  |   -- ASYNC --
tiktoksignature_1  |     at Frame.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:111:15)
tiktoksignature_1  |     at Page.evaluate (/usr/src/app/node_modules/puppeteer/lib/Page.js:860:43)
tiktoksignature_1  |     at Page.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/helper.js:112:23)
tiktoksignature_1  |     at Signer.init (/usr/src/app/index.js:71:21)
tiktoksignature_1  |     at processTicksAndRejections (internal/process/task_queues.js:97:5)
tiktoksignature_1  | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
tiktoksignature_1  | (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Token doesnt work

I've hosted this on Heroku and can get the token response, but when I use the same token and specify the same user-agent, I get no response from any of the URL endpoints I am trying to access.

If I use a valid token it does work, but the token produced by this is not working. Any ideas?

UnhandledPromiseRejectionWarning: Error: Failed to launch browser: Error: spawn /app/.cache/ms-playwright/webkit-1219/pw_run.sh ENOENT

Have just downloaded the updates to this repo and when I run

node listen.js

I get this error:

TikTok Signature server started
(node:23) UnhandledPromiseRejectionWarning: Error: Failed to launch browser: Error: spawn /app/.cache/ms-playwright/webkit-1219/pw_run.sh ENOENT
at ChildProcess. (/app/node_modules/playwright-core/lib/server/processLauncher.js:56:20)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

unexpected token issue

After running node listen.js I get result:

`/home/ubuntu/workspace/nodetiktok/node_modules/tiktok-signature/index.js:9
userAgent =
^

SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/ubuntu/workspace/nodetiktok/node_modules/tiktok-signature/listen.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)`

Node server won't start - giving unexpected token error

After cloning the repository and installing dependencies, it happens when I try to run the server:
node listen.js

`c:\git\experiment\tiktok-signature\index.js:9
userAgent =
^

SyntaxError: Unexpected token =
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (c:\git\experiment\tiktok-signature\listen.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)`

Am I missing something?

Thank you!

how can i implement this to iOS

I am a front end developer and I am wondering if there's a way I can implement this to track tiktok account stats, thanks!

Replace Tac Token

Hello, it's great to have other developers working on the api for tiktok :)

I generated a signature but it's invalid, in the read.me file it's suggest to replace the tac token in the signature.js file, but i didn't find the right way.

Can you explain this step with more details ?
Thank you and happy holidays

It only can call once using listen.js

I tried to use listen.js to make an api for remote calling, but it only can run once, then it would return same signature.

I solved this problem via child_process to run browser.js for every request, but seems not so good, what can I do else? And who knows that can I run it with serverless, maybe better on AWS Lambda...

thx

Trending.py just stopped working, empty response

If I open the resulting URL in Chrome I get the normal response. But in python it fails with

Traceback (most recent call last): File "trend.py", line 15, in <module> data = request.json() File "/Library/Python/2.7/site-packages/requests/models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads return _default_decoder.decode(s) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

Basically the response is empty when you get it via Python. Is there something to change in the headers?

Signature seems to be not working for me.

Hi,
I am trying to get _signature for two endpoints

https://m.tiktok.com/api/user/detail/?uniqueId=someuser&language=en&verifyFp=&_signature

and

https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyF p=&_signature=

I cloned your repo and started server

node server.js

and tried to run both these scripts signature.js and browser.js with endpoint.

node browser.js "https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyFp=&_signature="

and

node signature.js "https://m.tiktok.com/share/item/listsecUid=someid&id=1234&type=1&count=30&minCursor=0&maxCursor=0&shareUid=&lang=&verifyFp=&_signature="

I am getting the signature back but when I am hitting the request through curl with same signature with the endpoint, I am getting this response

{
    "statusCode": 200,
    "contentType": "application/json",
    "content": ""
}

While hitting through curl I am using the same user-agent as it is there in browser.js or signature.js.
Any idea I am doing something wrong?
Your help will be highly appreciated.

Adding docs about signature

Hey ! I have read the all the source files, and wanted first to say it's very impressive to see this solution :) great work !

So what I wanted to ask is can you may add references (links, docs) about:

  1. how you got the generateSignature code?
  2. how does works?
  3. does this thing has a name? (is it like a common mechanism in the industry or is it something only related to tiktok)?

maybe I'm missed that. but the main goal for me is to understand something when I use it, in case it breaks - I maybe can help out.
(Just to be clear, I'm not experienced in this area, but I want to get better, so basically asking for a starting point by getting more information about this rep)

and @carcabot if there is a way I can contact you out of github it'd be awesome.

UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: window.webpackJsonp is not iterable

I cloned the repo, installed the required packages and ran node listen.js, which resulted in the following error:

PS C:\Users\robin\source\repos\tiktok-signature> node .\listen.js
TikTok Signature server started
(node:416) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: window.webpackJsonp is not iterable
    at __puppeteer_evaluation_script__:4:28
    at ExecutionContext._evaluateInternal (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\ExecutionContext.js:122:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\ExecutionContext.js:48:12)
    at async Signer.init (C:\Users\robin\source\repos\tiktok-signature\index.js:73:5)
  -- ASYNC --
    at ExecutionContext.<anonymous> (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\helper.js:111:15)
    at DOMWorld.evaluate (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\DOMWorld.js:112:20)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  -- ASYNC --
    at Frame.<anonymous> (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\helper.js:111:15)
    at Page.evaluate (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\Page.js:860:43)
    at Page.<anonymous> (C:\Users\robin\source\repos\tiktok-signature\node_modules\puppeteer\lib\helper.js:112:23)
    at Signer.init (C:\Users\robin\source\repos\tiktok-signature\index.js:73:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:416) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Do you have any idea why "window.webpackJsonp is not iterable", since it was working before? Did TikTok change stuff again?

how to get detail

Signature token is not working

Generated tokens are not working anymore. It started on Jan 9. Seems tiktok has changed the way they are generating tokens again. Can someone provide a fix for this? Thanks

Browser.js not generating correct signature.

Following is the url I am trying to generate the URL with

node browser.js "https://m.tiktok.com/share/item/list?secUid=MS4wLjABAAAAiWABcA0z8O_trkXaALB5r2El1C8oUVABE3dGlt8AnxY&id=16631823&type=1&count=30&minCursor=0&maxCursor=0&shareUid="
s0Ju9AAgEBCwzpufd4evy7NCb-AAO0V

The user agent used for getting the info of the user is the same as being sent in the final request with signature but it doesnt work.

signature.js not valid token

can you update the signature.js ?
because not work again, but the browser.js still OK

i need the signature.js working again:(

how to get tac

i get signature and try to request comment api but signature not work. for the respone
{"statusCode":200,"contentType":"application/json","content":""},how to get a new tac?

UnhandledPromiseRejectionWarning: Error: Page crashed!

Just noticed the local http server logged this error into the console, I'm unsure what caused this as I was not monitoring the system at the time of the error, but it does result in browser.js failing to produce a valid token. The stacktrace, unfortunately in a bad format, below:

image

Is it possible that the js file could require some extra error handling to prevent crashes like this?

If it's of any more help, I tried manually executing browser.js and it returned this error:

image

Line 48 in index.js for me is await this.page.goto("http://tiktok.com:8080/index.html", {

Error: Evaluation failed: ReferenceError: generateSignature is not defined

hi, after installing and running listen.js i get this error:

TikTok Signature server started
Received url: https://m.tiktok.com/share/item/list?secUid=&id=&type=5&count=30&minCursor=0&maxCursor=0&shareUid=
Error: Evaluation failed: ReferenceError: generateSignature is not defined
    at __puppeteer_evaluation_script__:1:1
    at ExecutionContext._evaluateInternal (/root/test/node_modules/puppeteer/lib/ExecutionContext.js:56:23)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (/root/test/node_modules/puppeteer/lib/ExecutionContext.js:33:16)
    at async Signer.sign (/root/test/node_modules/tiktok-signature/index.js:98:15)
    at async IncomingMessage.<anonymous> (/root/test/node_modules/tiktok-signature/listen.js:38:27)
  -- ASYNC --
    at ExecutionContext.<anonymous> (/root/test/node_modules/puppeteer/lib/helper.js:94:19)
    at DOMWorld.evaluate (/root/test/node_modules/puppeteer/lib/DOMWorld.js:89:24)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
  -- ASYNC --
    at Frame.<anonymous> (/root/test/node_modules/puppeteer/lib/helper.js:94:19)
    at Page.evaluate (/root/test/node_modules/puppeteer/lib/Page.js:591:14)
    at Page.<anonymous> (/root/test/node_modules/puppeteer/lib/helper.js:95:27)
    at Signer.sign (/root/test/node_modules/tiktok-signature/index.js:98:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async IncomingMessage.<anonymous> (/root/test/node_modules/tiktok-signature/listen.js:38:27)
(node:6886) UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded
    at /root/test/node_modules/puppeteer/lib/LifecycleWatcher.js:100:111
  -- ASYNC --
    at Frame.<anonymous> (/root/test/node_modules/puppeteer/lib/helper.js:94:19)
    at Page.goto (/root/test/node_modules/puppeteer/lib/Page.js:476:53)
    at Page.<anonymous> (/root/test/node_modules/puppeteer/lib/helper.js:95:27)
    at Signer.init (/root/test/node_modules/tiktok-signature/index.js:61:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:6886) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6886) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Unexpected token at index.js:9

Hi! First of all thanks for sharing this, it's really helpful.

I'm trying to run the program like this:

node browser.js "https://m.tiktok.com/node/video/feed"

and this is throwing this error:

  userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
            

SyntaxError: Unexpected token =
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/mathi/Escritorio/tiktokapi/tiktok-signature/browser.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

I'm pretty new with node-js so it might be because of some really basic error I made. Please let me know if anyone experienced the same or if you know what could be the problem :) Thanks!

Donation (Patreon/BTC/...)

You have helped many of us here a lot. You have been really fast at fixes and as soon as my service goes up again I would like to give you a bit of beer money. Maybe some others want to drop a coin as well.

Do you have a tip jar? If you are doing it completely free that is also very nice but maybe as a little gesture from us

Unwanted audio when signer is initiated.

When using webkit or firefox with playwright, by default, pages are not muted, which means that the trending page's audio starts to play when the signer is initiated.

I know that chromium has a "--mute-audio" startup flag, but I see that you are using webkit instead; which of I could not find the equivalent flag.

Would it be safe to switch over to chromium, or maybe find a way to mute a page in webkit?

How to get Video without watermark

itemInfos got from "/share/item/list", hava a video url. But the url indicates a video with watermark, do you know how to get video url without watermark.
thk u!

Puppeteer Being Detected

Hey there, I'm having an issue using the signature in urls that follow the format below

https://m.tiktok.com/api/user/detail/?uniqueId=accountName&language=en&verifyFp=&_signature=generatedSignature

This is the right formatting for the URL as I just copy and pasted it from my chrome network tab and it correctly works if I run it with an account name and my signature generated on my chrome browser not puppeteer.

This should be the expected output for @worldeconomicforum

{"statusCode":0,"userInfo":{"user":{"id":"6618914290789908486","uniqueId":"worldeconomicforum","nickname":"World Economic Forum","avatarThumb":"https://p16-va-default.akamaized.net/img/musically-maliva-obj/1628353390516229~c5_100x100.jpeg","avatarMedium":"https://p16-va-default.akamaized.net/img/musically-maliva-obj/1628353390516229~c5_720x720.jpeg","avatarLarger":"https://p16-va-default.akamaized.net/img/musically-maliva-obj/1628353390516229~c5_1080x1080.jpeg","signature":"International Organization, committed to improving the state of the world","verified":true,"secUid":"MS4wLjABAAAAgEx3966_YUbYFKj_uooXzT2gb2EvV8NrdvJDKKPdxPjuH1XqPC_vEg7ZuUeM4GSY","secret":false,"relation":0,"openFavorite":false},"stats":{"followingCount":66,"followerCount":1235007,"heartCount":13830567,"videoCount":276,"diggCount":14,"heart":13830567},"shareMeta":{"title":"World Economic Forum on TikTok","desc":"@worldeconomicforum 1.0m Followers, 66 Following, 13.0m Likes - Watch awesome short videos created by World Economic Forum"}}}

Here's the base url for that account that doesn't seem to work.

https://m.tiktok.com/api/user/detail/?uniqueId=worldeconomicforum&language=en&verifyFp=

Update:
It seems like the issue is with any url that doesn't follow the format

https://m.tiktok.com/api/item_list/

As the links below don't seem to work

This link is used for probably more than just to get tiktoks by a music id, but that's what I'm using it for.

https://m.tiktok.com/share/item/list

Also with which is the initial reason for the issue.

https://m.tiktok.com/api/user/detail/

Edit: @mitchhymel helped figure out here that it seems to be an issue of Puppeteer being detected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.