From dd94ff0011f97fcce912d5b06c795ecf9179ad9b Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Sat, 13 Aug 2022 12:17:45 +0200 Subject: [PATCH] Added some examples --- README.md | 2 ++ examples/example.js | 19 +++++++++++++++++++ examples/example.py | 16 ++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 examples/example.js create mode 100644 examples/example.py diff --git a/README.md b/README.md index 494dbdb..737f5bd 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ You can send a POST request to http://localhost:8080/signature with a raw/plain If you plan to use the already deployed Vercel version, you should use https://signtok.vercel.app/api/signature +You can see some examples [here](https://github.com/pablouser1/SignTok/blob/master/examples) + ### Cli ``` node local.js 'YOUR_URL_HERE' diff --git a/examples/example.js b/examples/example.js new file mode 100644 index 0000000..3199528 --- /dev/null +++ b/examples/example.js @@ -0,0 +1,19 @@ +/** + * Example using native fetch +*/ + +// You can replace this with your signing instance +const SIGNING_URL = 'http://localhost:8080/signature' + +const EXAMPLE_URL = 'https://m.tiktok.com/api/post/item_list?count=30&id=6941611380308870149&cursor=0&type=1&secUid=MS4wLjABAAAA7DfOn_jwWM7Rscrl2SGPW06eYI0bUDXRoRoTcSpw_Bsndydsbk8zH3tZe2Tz9FoJ&sourceType=8&appId=1233&aid=1988&app_language=en&app_name=tiktok_web&browser_language=en-us&browser_name=Mozilla&browser_online=1&browser_platform=iPhone&browser_version=Mozilla%252F5.0%2B%2528Macintosh%253B%2BIntel%2BMac%2BOS%2BX%2B10_15_6%2529%2BAppleWebKit%252F537.36%2B%2528KHTML%252C%2Blike%2BGecko%2529%2BChrome%252F98.0.4758.109%2BSafari%252F537.36&channel=tiktok_web&cookie_enabled=1&device_platform=web_mobile&focus_state=1&history_len=3&is_fullscreen=0&is_page_visible=1&os=ios&priority_region=&referer=®ion=us&screen_width=1920&screen_height=1080&timezone_name=America%2FChicago&webcast_language=en&device_id=9632257621121311443' + +fetch(SIGNING_URL, { + method: 'POST', + body: EXAMPLE_URL +}).then( + plain => plain.json() +).then(res => { + console.log(res.data.signed_url) +}).catch(err => { + console.error(err) +}) diff --git a/examples/example.py b/examples/example.py new file mode 100644 index 0000000..b4163de --- /dev/null +++ b/examples/example.py @@ -0,0 +1,16 @@ +import requests + +""" +Example using Python requests +""" + +# You can replace this with your signing instance +SIGNING_URL = 'http://localhost:8080/signature' + +EXAMPLE_URL = 'https://m.tiktok.com/api/post/item_list?count=30&id=6941611380308870149&cursor=0&type=1&secUid=MS4wLjABAAAA7DfOn_jwWM7Rscrl2SGPW06eYI0bUDXRoRoTcSpw_Bsndydsbk8zH3tZe2Tz9FoJ&sourceType=8&appId=1233&aid=1988&app_language=en&app_name=tiktok_web&browser_language=en-us&browser_name=Mozilla&browser_online=1&browser_platform=iPhone&browser_version=Mozilla%252F5.0%2B%2528Macintosh%253B%2BIntel%2BMac%2BOS%2BX%2B10_15_6%2529%2BAppleWebKit%252F537.36%2B%2528KHTML%252C%2Blike%2BGecko%2529%2BChrome%252F98.0.4758.109%2BSafari%252F537.36&channel=tiktok_web&cookie_enabled=1&device_platform=web_mobile&focus_state=1&history_len=3&is_fullscreen=0&is_page_visible=1&os=ios&priority_region=&referer=®ion=us&screen_width=1920&screen_height=1080&timezone_name=America%2FChicago&webcast_language=en&device_id=9632257621121311443' + +r = requests.post(SIGNING_URL, data=EXAMPLE_URL) + +if r.ok: + r_json = r.json() + print(r_json['data']['signed_url'])