0

What PHP code will embed the video with unique token based link for each viewers?

My OneDrive video original download link creates an unique token based link for each viewers on my webpage. Normally to embed the video on my webpage, I directly write my original video link. But I want a PHP code which will embed the video with token link so when a person open source code of my webpage they will see the token based link not my original link. Let me clarify more; A person click the watch now button. He gets redirected to the webpage where I have embedded the video. PHP code should run the downlad video link in backend. The downlad link automatically creates unique link so we don't need any code to have token based link. Now Auto generated token based downlad link should be embedded on my webpage. So if a person tries to copy it then that link will be useless.

14th May 2020, 8:43 AM
Ashish Sah
Ashish Sah - avatar
2 ответов
+ 1
I've seen you start off a lot of your questions with "What code will do x". The issue with this is that it all depends on the implementation of the rest of your service. You also don't learn anything simply by asking others for the exact solution. Instead of asking "what do I type to do x?", Ask "How would I approach x?".
29th May 2020, 3:47 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar
+ 1
How I would do this (this system can certainly be improved but I'm thinking aloud here) is when the user clicks the "Watch Now" button, it sends a request to the server asking for a unique link. The link would look like this: "https://example.com/play_video.php?id=UUID". The server would generate this by first using some UUID generator (I'm sure you can find some easy PHP implementations by Googling around) to generate a unique id. Then it would make a request to the database to add an entry with the UUID and the video file (possibly some more stuff if you'd like to do analytics). The server would then send the unique link to the front end and from there you could automatically redirect the user using JS. Once the user visits the play_video.php script, the UUID would be retrieved from the get query and looked up in the database. The database would return the actual video file and the script would load it in. The video file would only be accessable on the back end. The user would simply see the unique id URL
29th May 2020, 3:55 PM
Ben Allen (Njinx)
Ben Allen (Njinx) - avatar