Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
1,680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <?php
  2.  
  3. /* connect to gmail */
  4. $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
  5. $username = 'example_email_address@gmail.com' ;
  6. $password = 'password';
  7.  
  8. /* try to connect */
  9. $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
  10.  
  11. /* grab emails */
  12. $emails = imap_search($inbox,'ALL');
  13.  
  14. /* if emails are returned, cycle through each... */
  15. if($emails) {
  16.  
  17. /* begin output var */
  18. $output = '';
  19.  
  20. /* put the newest emails on top */
  21. rsort($emails);
  22.  
  23. /* for every email... */
  24. foreach($emails as $email_number) {
  25.  
  26. /* get information specific to this email */
  27. $overview = imap_fetch_overview($inbox,$email_number,0);
  28. $message = imap_fetchbody($inbox,$email_number,2);
  29.  
  30. // $regex = '/b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]/i';
  31. // preg_match_all($regex, $message, $matches);
  32. // $urls = $matches[0];
  33. // // go over all links
  34. // foreach($urls as $url)
  35. // {
  36. // echo $url.'<br />';
  37. // }
  38.  
  39. // $dom = new DOMDocument;
  40. // //$dom->loadXML($message);
  41. // $dom->loadHTML($message);
  42. // $anchortags = $dom->getElementsByTagName('a');
  43. // foreach ($anchortags as $anchortag) {
  44. // echo $anchortag->nodeValue, PHP_EOL;
  45. // preg_match('//([w_-]+(?:(?:.[w_-]+)+))([w.,@?^=%&:/~+#-]*[w@?^=%&/~+#-])?', $anchortag, $matches);
  46. // }
  47.  
  48.  
  49.  
  50. // /* output the email header information */
  51. // $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
  52. // $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
  53. // $output.= '<span class="from">'.$overview[0]->from.'</span>';
  54. // $output.= '<span class="date">on '.$overview[0]->date.'</span>';
  55. // $output.= '</div>';
  56.  
  57. // /* output the email body */
  58. // $output.= '<div class="body">'.$message.'</div>';
  59. }
  60.  
  61. echo $output;
  62. }
  63.  
  64. function get_data($url) {
  65. $ch = curl_init();
  66. $timeout = 5;
  67. curl_setopt($ch, CURLOPT_URL, $url);
  68. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  69. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  70. $data = curl_exec($ch);
  71. curl_close($ch);
  72. return $data;
  73. }
  74.  
  75. $returned_content = get_data('https://dash-jci.s3.amazonaws.com/February_11_2017/Feb_11_2017-1486798132143.zip?response-cache-control=max-age%3D31536000&response-content-type=application%2Fzip&AWSAccessKeyId=AKIAJREL4U5PR4NTGPKA&Expires=2135333220&Signature=8FxLAICc89HQMc98LQH6dsIYyp4%3Dfff');
  76.  
  77.  
  78.  
  79. /* close the connection */
  80. imap_close($inbox);
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement