Advertisement
danfried

Untitled

Jun 22nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. //this is your shortlink.php file
  3. require_once $_SERVER['DOCUMENT_ROOT'] . '/path/config.php';
  4.  
  5.  
  6. /* Create a shortlink from the given URL. Only needs to be valid for about 20 minutes. */
  7. function shortlink_create(string $longurl) {
  8. global $cfg_shortlink;
  9. global $cfg_shortlink_key;
  10. global $RandomNumber;
  11.  
  12. $result = @json_decode(file_get_contents($cfg_shortlink[$RandomNumber] . $cfg_shortlink_key[$RandomNumber] . "&url=" . urlencode($longurl)), true);
  13.  
  14. if($result['status'] === 'error')
  15. die($result['message']);
  16. else
  17. return $result['shortenedUrl'];
  18. }
  19.  
  20. ?>
  21. <?php
  22. // this is what should be in your config file
  23. // Shortlink ApiKeys
  24. // NOTE: api keys and links should match up in the arrays
  25. $cfg_shortlink_key[0] = '';
  26. $cfg_shortlink_key[1] = '';
  27. $cfg_shortlink_key[2] = '';
  28. $cfg_shortlink_key[3] = '';
  29. $cfg_shortlink_key[4] = '';
  30. $cfg_shortlink_key[5] = '';
  31. $cfg_shortlink_key[6] = '';
  32. $cfg_shortlink_key[7] = '';
  33.  
  34. // Shortlink Apis
  35. $cfg_shortlink[0] = 'https://oturl.com/api?api=';
  36. $cfg_shortlink[1] = 'https://linkrex.net/api?api=';
  37. $cfg_shortlink[2] = 'http://oke.io/api/?api=';
  38. $cfg_shortlink[3] = 'https://short2win.com/api?api=';
  39. $cfg_shortlink[4] = 'https://oturl.com/api?api=';
  40. $cfg_shortlink[5] = 'https://ourl.io/api?api=';
  41. $cfg_shortlink[6] = 'https://link4win.com/api?api=';
  42. $cfg_shortlink[7] = 'https://cashat.net/api?api=';
  43.  
  44. $RandomNumber = mt_rand(0,7);
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement