Advertisement
Guest User

Untitled

a guest
Jul 6th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php
  2. require_once('class.smtp.php');
  3. require_once("class.phpmailer.php");
  4.  
  5. $page_access_token = 'NOPE';
  6. $page_id = 'NOPE';
  7.  
  8. function mailto($to, $subject, $body){
  9.     $mail = new PHPMailer();
  10.     $mail->IsSMTP();  // telling the class to use SMTP
  11.     $mail->SMTPAuth = true;
  12.     $mail->Host     = 'mail.osp.naklo.pl'; // SMTP server
  13.     $mail->Port     = 587;
  14.     $mail->Username = 'NOPE@osp.naklo.pl';
  15.     $mail->Password = 'NOPE';
  16.     $mail->SMTPSecure = 'tls';
  17.     $mail->CharSet = "UTF-8";
  18.     $mail->SetFrom('NOPE@osp.naklo.pl', 'OSP Nakło nad Notecią');
  19.     $mail->AddAddress($to);
  20.     $mail->Subject  = $subject;
  21.     $mail->Body     = $body;
  22.     $mail->WordWrap = 50;
  23.  
  24.     if(!$mail->Send()) {
  25.                     print($mail->ErrorInfo);
  26.                   } else {
  27.                     print('success');
  28.                  }
  29. }
  30.  
  31. if($_POST['secret'] == "NOPE"){
  32.     mailto('NOPE@osp.naklo.pl', 'Alarm dla OSP!(' . time() . ')', 'Nasza jednostka właśnie została zaalarmowana.');
  33.  
  34.    
  35.  
  36.  
  37.     $data['picture'] = 'http://www.osp.naklo.pl/wp-includes/images/wezwanie.png';
  38.     $data['message'] = 'Nasza jednostka jest właśnie alarmowana';
  39.     #$data['profile'] = 'NOPE';
  40.    $data['access_token'] = $page_access_token;
  41.     $data['link'] = 'http://www.osp.naklo.pl/';
  42.  
  43.     $post_url = 'https://graph.facebook.com/'.$page_id.'/feed';
  44.     $ch = curl_init();
  45.     curl_setopt($ch, CURLOPT_URL, $post_url);
  46.     curl_setopt($ch, CURLOPT_POST, 1);
  47.     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  48.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  49.     $return = curl_exec($ch);
  50.     echo 'Curl error: ' . curl_error($ch);
  51.     curl_close($ch);
  52.     print_r($return);
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement