MyBB Community Forums

Full Version: tiktok video embed does not work with mybb
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Has anyone been able to develop a MyCode or a plugin to show tiktok videos in their forum?

Tiktok does not use iframes, but this code structure:
<blockquote 
class="tiktok-embed" cite="https://www.tiktok.com/@palermeando/video/1111111111111111111" data-video-id="1111111111111111111" style="max-width: 605px;min-width: 325px;" >
 <section> 
 </section> 
 </blockquote> 
 <script async src="https://www.tiktok.com/embed.js"></script>
You can create a simple MyCode:
Regular expression
\[tiktok\](https:\/\/www.tiktok.com\/@([^\/]+)\/video\/(.+))\[\/tiktok\]

Replacement
<blockquote class="tiktok-embed" cite="$1" data-video-id="$3" style="max-width: 605px;min-width: 325px;" > <section></section></blockquote> 
 <script async src="https://www.tiktok.com/embed.js"></script>

But I think it's better to load the jscript once, in the footer of showthread, to avoid multiple loads
(2022-01-02, 12:49 PM)Crazycat Wrote: [ -> ]You can create a simple MyCode:
Regular expression
\[tiktok\](https:\/\/www.tiktok.com\/@([^\/]+)\/video\/(.+))\[\/tiktok\]

Replacement
<blockquote class="tiktok-embed" cite="$1" data-video-id="$3" style="max-width: 605px;min-width: 325px;" > <section></section></blockquote> 
 <script async src="https://www.tiktok.com/embed.js"></script>

But I think it's better to load the jscript once, in the footer of showthread, to avoid multiple loads


Thank you very much, according to your help I did the following:

Title
TIKTOK MYBB

Description
TIKTOTK MYBB CODE

Regular Expresion
\[tiktok\](https:\/\/www.tiktok.com\/@([^\/]+)\/video\/(.+))\[\/tiktok\]

Replacement *
<blockquote class="tiktok-embed" cite="$1" data-video-id="$3" style="max-width: 605px;min-width: 325px;" > <section></section></blockquote> 
 <script async src="https://www.tiktok.com/embed.js"></script>

And then I tried the code in MyCode:
1) This works fine in the custom MyCode Test (test value)- ACP.)
with this example:
[TIKTOK]https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614[/TIKTOK]
2) But in a new theme it does not work remains blank, nothing is displayed.


user:test
pass: usernew
works well on my test server, check with you hoster if there is not any mod_security setting blocking the content.

I've tested on your forum using the default MyBB theme, same trouble, so the trouble doesn't came from MyBB, as the full post is not displayed
you can try something like this.

Regular Expression

\[tiktok\](.*?)\[\/tiktok\]

Replacement

<iframe width="560" height="750" src="https://www.tiktok.com/embed/v2/$1" frameborder="0" allowfullscreen></iframe>



How use:

[tiktok]video id here[/tiktok]

if link is
https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614
will become
[tiktok]6983849075741412614[/tiktok]

based from https://stackoverflow.com/a/70193436

if code above work so you can try

Regular Expression

\[tiktok\](https:\/\/www.tiktok.com\/@([^\/]+)\/video\/(.+))\[\/tiktok\]

Replacement

<iframe width="560" height="750" src="https://www.tiktok.com/embed/v2/$3" frameborder="0" allowfullscreen></iframe>



How use:

[tiktok]video url here[/tiktok]

if link is
https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614

will become
[tiktok]https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614[/tiktok]
(2022-01-03, 01:21 AM)martec Wrote: [ -> ]you can try something like this.

Regular Expression

\[tiktok\](.*?)\[\/tiktok\]

Replacement

<iframe width="560" height="750" src="https://www.tiktok.com/embed/v2/$1" frameborder="0" allowfullscreen></iframe>



How use:

[tiktok]video id here[/tiktok]

if link is
https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614
will become
[tiktok]6983849075741412614[/tiktok]

based from https://stackoverflow.com/a/70193436

if code above work so you can try

Regular Expression

\[tiktok\](https:\/\/www.tiktok.com\/@([^\/]+)\/video\/(.+))\[\/tiktok\]

Replacement

<iframe width="560" height="750" src="https://www.tiktok.com/embed/v2/$3" frameborder="0" allowfullscreen></iframe>



How use:

[tiktok]video url here[/tiktok]

if link is
https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614

will become
[tiktok]https://www.tiktok.com/@bonus_track_punto_reflex/video/6983849075741412614[/tiktok]

Thank you very much, both codes for MyCode work perfectly.
They do not produce any blockage. I think the video was blocked by the execution of the tiktok script from the above code.
Solved.
Cool Smile
Does this works for TikTok videos copied from mobile app? It didn't work for me, I don't understand whenever it is TikTok issue or hosting issue
You would need to expand on what "didn't work" means. It would need to be the right URL, one that allows embedding.
(2022-07-28, 10:40 PM)Matt Wrote: [ -> ]You would need to expand on what "didn't work" means. It would need to be the right URL, one that allows embedding.

Thanks for the reply, it wasn't parsing it, it was hosting issue, they already fixed it now working fine