lscofield

Retrieve direct vidoza URL with API

Jun 10th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Getting direct vidoza URL
  5.  * using node-urlresolver-api API by @lscofield
  6.  * This script is only tested with vidoza links
  7.  */
  8.  
  9. // vidoza test url
  10. // You can test with another link if this link go down
  11. $url = 'https://vidoza.net/x1l6wnmde215.html';
  12. // Create curl instance (GET)
  13. $ch = curl_init();
  14. //Set the URL that you want to GET by using the CURLOPT_URL option.
  15. curl_setopt($ch, CURLOPT_URL, $url);
  16. //Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  18. //Set CURLOPT_FOLLOWLOCATION to false to follow redirects.
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
  20. // Set referer for mixdrop request
  21. curl_setopt($ch, CURLOPT_REFERER, $url);
  22. //Execute the request.
  23. $html = curl_exec($ch);
  24. //Close the cURL handle.
  25. curl_close($ch);
  26.  
  27. // Encode the html code to base64
  28. $html = base64_encode($html);
  29. $host = "vidoza"; // in this case
  30. $api_endpoint = "http://yourdomain/api/v1/$host";
  31. // Prepare POST params
  32. // Prepare auth param
  33. $auth = '{"auth":"","skk":"your_app_key_from_config"}';
  34. // Encode auth to base64
  35. $auth = base64_encode($auth);
  36. $params = array(
  37.   "source" => $html,
  38.   "auth" => $auth
  39. );
  40.  
  41. $params = json_encode($params);
  42. // Create curl instance (POST) to get direct
  43. // URL with API
  44. $ch = curl_init($api_endpoint);
  45. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  46. curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  47. curl_setopt($ch, CURLOPT_POST, true);
  48. curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  49. // Set HTTP Header for POST request
  50. curl_setopt(
  51.   $ch,
  52.   CURLOPT_HTTPHEADER,
  53.   array(
  54.     'Content-Type: application/json',
  55.     'Content-Length: ' . strlen($params)
  56.   )
  57. );
  58. // Submit the POST request
  59. $result = curl_exec($ch);
  60. // Close cURL session handle
  61. curl_close($ch);
  62.  
  63.  
  64. if ($result) {
  65.   // Convert to json
  66.   $result = json_decode($result);
  67.   // Print direct url (format: .mp4 or .m3u8)
  68.   // player to be play in
  69.   // the media player
  70.   echo $result->url;
  71.   // Note if the app_key set in post auth
  72.   // not match with the app_key that you
  73.   // has in your server config file
  74.   // $resul->url will have a random troll mp4 video
  75.   // If vidoza url is down $result->url will have empty string
  76. } else {
  77.   // No data fetched
  78.   // Typically API or SERVER issue
  79. }
Add Comment
Please, Sign In to add comment