Reputation: 37
I have API which changing its data on every hour. Example output:
{"status":true,"hash":"yJscAtmUB0IXz1SZ","link":"https://url.com/video.m3u8","thumbnail":""}
Actually just link is changing on every hour. That link I'am using to stream video via player.js. For example:
mysite.com/watchvideo.php?url=**link-by-api**
I cant figure out how to get the new link which is changing.
Upvotes: 1
Views: 218
Reputation: 454
Solution 1 :
write a php code in your project that checks if it was more that 1 hours , get the new link .
<?php
$dateTime = strtotime('now'); // Get current time in seconds
$difference = $dateTime - $updatedTime; // Get Difference Between Right Now And Updated Time
// $updatedTime is the last time api link is updated
// you should store the last updateDate in somewhere ...
if ($difference >= 3600) { // 3600 seconds = 1 hour
// Update the api link
}
Solution 2 :
you can use cron job to run this php file every 1 hour and store the api-link into the database
Upvotes: 1