Closed georgesabin closed 3 years ago
Stream class won't put our the video streaming url, instead it will stream the video
So,
you need to create stream.php
file which will take a url param like videoUrl
or something so you in your stream.php
file you can do something like
///some initializations
$streamer->stream(base64_decode(urldecode($_GET['videoUrl'])));
then in your video tag you do something like
<source src="stream.php?videoUrl=<?php echo urlencode(base64_encode(($tikTok['playAddr'])); ?>" type="video/mp4">
Thank you for the response.
I did exactly what you said, but now I received a 403 status code, Forbidden.
Do you have any idea why?
P.S.: I'm using wordpress.
Thanks!
You should create ajax hook using WP hook which will handle the streaming function and use that ajax url in video src attribute.
https://developer.wordpress.org/reference/hooks/wp_ajax_action/
Use something like this in your theme's functions.php
or plugin file
add_action('wp_ajax_tt_video_stream','tiktok_video_streamer');// for logged in users
add_action('wp_ajax_nopriv_tt_video_stream','tiktok_video_streamer'); // for non logged in users
function tiktok_video_streamer(){
// this handles the ajax request when action=tt_video_stream
$url=base64_decode(url_decode($_GET['url']));
$streamer->stream($url); // assuming you already have created $streamer instance
die();
}
In your video tag
<source src="<?php echo admin_url('admin-ajax.php')?action=tt_video_stream&url=<?php echo urlencode(base64_encode(($tikTok['playAddr'])); ?>" type="video/mp4">
I tried in this way, but without success also.
I still get 403 https://ibb.co/syQkjkx
The stream instance should be with a cookie file from tik tok?
Make sure the cookie_file
are the same when initializing both Streamer & Api classes. This library handles the cookies across so it shouldn't matter.
This issue is unrelated to the library. You should hire WordPress expert for the integration if you don't have experience with WP ajax.
Understand, but for getTrendingFeed method works fine and for getChallengeFeed not working.
Resolved! Cookie file was the problem.
Ssovit, thanks for the suport!
P.S.: Amazing API, good job!
Hi!
I tried to use your example from the stream.
Can you tell me if I'm using correct the stream?
https://ibb.co/JqRgKJk