Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Get List Google Drive</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  9. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  10. </head>
  11. <body>
  12. <div class="container">
  13. <h2>Get List Google Drive</h2>
  14. <table class="table table-hover table-bordered">
  15. <thead>
  16. <tr>
  17.  
  18. <th>Name</th>
  19. <th>Url</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <?php
  24. function curl($url){
  25. $ch = @curl_init();
  26. curl_setopt($ch, CURLOPT_URL, $url);
  27. $head[] = "Connection: keep-alive";
  28. $head[] = "Keep-Alive: 300";
  29. $head[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  30. $head[] = "Accept-Language: en-us,en;q=0.5";
  31. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36');
  32. curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  35. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  36. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  37. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
  38. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  39. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
  40. $page = curl_exec($ch);
  41. curl_close($ch);
  42. return $page;
  43. }
  44. function api_drive($url) {
  45. $id = explode("/",$url);
  46. $urlget = "https://www.googleapis.com/drive/v2/files?q=%27$id[5]%27%20in%20parents&maxResults=9999&key=AIzaSyCISllkltIqYjJs35a3mLkJ5iT-awGrNpA";
  47. $json = curl($urlget);
  48. $array = json_decode($json,true);
  49. $item = $array["items"];
  50. for($i=0;$i<count($item);$i++) {
  51. $return[$i]['embedLink'] = $item[$i]['embedLink'];
  52. $return[$i]['title'] = $item[$i]['title'];
  53. $html .="<tr>
  54.  
  55. <td>".$return[$i]['title']."</td>
  56. <td>".$return[$i]['embedLink']."</td>
  57. </tr>";
  58. }
  59. return $html;
  60. }
  61. $url = $_GET['url'];
  62. echo api_drive($url);
  63. ?>
  64.  
  65. </tbody>
  66. </table>
  67. </div>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement