0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Get ogp equivalent information on TikTok via API (Ruby)

Last updated at Posted at 2024-06-04

I was writing a process to scrape TikTok and get the OGP information, but before I knew it, it was being rejected with status code 1000, as shown below.
[25] pry(main)> html = open(movie_url) do |f| f.read; end => "{\"statusCode\":10000,\"verifyConfig\":{\"code\":10000,\"type\":\"verify\",\"subtype\":\"slide\",\"fp\":\"verify_5f101e29a0ad54278347a24437cfcb93\",\"region\":\"sg\",\"detail\":\"2SdJGObfW85-lX4dEGohkmh8YbPmZYiXwIh1pqrEUuohsJqr4t3XjgXHtkBHWheNJbj4MB*CVwF1ayKFmhUFcJY2yAgBxyatF0XXzv0*xk*DmEz7Og6oE0nS1mFuZXdkJE*Z05uOnCgTkh4d4yy7xfv6EiiQJGBxdHDxp21vXCZjphcNMaY6YoCrq-5wRulWVle0lP3RJyqJQUFbtIP8pH0LICH8SRGn9a6mItvTEiEwiHCfJHBxhTUf1kFCYkGm1gBpVE1s45qbaNPeVELCCU0732nlU1VLR7Jm16yTIne64NABwJSaXFAl19NrjsfHrV-Cxq*d4kuVUBERzDIIncNGgQ3m6MLdwGLw*H4xfl94O1LId2V5zlOltVL1gYtral9VUYNMskUBWclUpWt2zrUfpbVzuUg.\"}}"

I wondered what to do, but after some research, I found that I could get information equivalent to OGP through TikTok's API, so I modified it to get it through the API. There is documentation, so it's not that difficult.

https://www.tiktok.com/oembed?url=https://www.tiktok.com/@scout2015/video/6718335390845095173

All you have to do is pass the TikTok URL you want to get information about to the url parameter and hit https://www.tiktok.com/oembed . You will get a response like this:

{ "version": "1.0", "type": "video", "title": "Scramble up ur name & I’ll try to guess it😍❀️ #foryoupage #petsoftiktok #aesthetic", "author_url": "https://www.tiktok.com/@scout2015", "author_name": "Scout & Suki", "width": "100%", "height": "100%", "html": "<blockquote class=\"tiktok-embed\" cite=\"https://www.tiktok.com/@scout2015/video/6718335390845095173\" data-video-id=\"6718335390845095173\" style=\"max-width: 605px;min-width: 325px;\" > <section> <a target=\"_blank\" title=\"@scout2015\" href=\"https://www.tiktok.com/@scout2015\">@scout2015</a> <p>Scramble up ur name & I’ll try to guess it😍❀️ <a title=\"foryoupage\" target=\"_blank\" href=\"https://www.tiktok.com/tag/foryoupage\">#foryoupage</a> <a title=\"petsoftiktok\" target=\"_blank\" href=\"https://www.tiktok.com/tag/petsoftiktok\">#petsoftiktok</a> <a title=\"aesthetic\" target=\"_blank\" href=\"https://www.tiktok.com/tag/aesthetic\">#aesthetic</a></p> <a target=\"_blank\" title=\"♬ original sound - π‡πšπ°πšπ’π’π“†‰\" href=\"https://www.tiktok.com/music/original-sound-6689804660171082501\">♬ original sound - π‡πšπ°πšπ’π’π“†‰</a> </section> </blockquote> <script async src=\"https://www.tiktok.com/embed.js\"></script>", "thumbnail_width": 720, "thumbnail_height": 1280, "thumbnail_url": "https://p16.muscdn.com/obj/tos-maliva-p-0068/06kv6rfcesljdjr45ukb0000d844090v0200010605", "provider_url": "https://www.tiktok.com", "provider_name": "TikTok" }

Code (ruby)

uri = URI.parse("https://www.tiktok.com/oembed?url=#{params[:tiktok_url]}") response = Net::HTTP.get_response(uri) res_json = JSON.parse(response.body) html_doc = res_json["html"] title = res_json["title"] ogp_image = res_json["thumbnail_url"]

5 Easy Steps to Download TikTok Videos on Your iPhone:

Step 1: Grab That TikTok Link

β€’ Open up TikTok on your iPhone
β€’ Find the video you're dying to save
β€’ Tap that Share button in the bottom right corner
β€’ Hit "Copy Link" and you're golden!

Step 2: Safari Time!

β€’ Open Safari on your iPhone
β€’ Head over to TiktokSSS.app.

Step 3: Paste and Download

β€’ Paste your TikTok link into the search box on TiktokSSS
β€’ Tap that Download button
β€’ Choose the "Download without logo" option for a clean video

Step 4: Find Your Downloaded Video

β€’ Open your Files or Photos app
β€’ Check out the Downloads folder or Photos album
β€’ Pro tip: Use the search feature in Files or Photos to find your video faster!

Step 5: Share or Edit Your Video

β€’ Share directly to Facebook, Instagram, or send it in a message
β€’ Want to get creative? Use apps like iMovie, Adobe Premiere Rush, or InShot to edit your video

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?