Skip to content

Instantly share code, notes, and snippets.

@melnikovdv
Last active October 9, 2015 11:37
Show Gist options
  • Save melnikovdv/3497646 to your computer and use it in GitHub Desktop.
Save melnikovdv/3497646 to your computer and use it in GitHub Desktop.
http notification from Yandex.Money
<?php
/*
Это пример скприпта, который обрабатывает http-уведомление Яндекс.Денег и затем отсылает его по email.
Подробнее про http-нотификации здесь: http://api.yandex.ru/money/doc/dg/reference/notification-p2p-incoming.xml
Warning!
Используется PHP-extension PEAR для отправки email.
*/
ini_set("include_path",".:/home/mdv/pear/php");
ini_set('display_errors','On');
require_once "Mail.php";
print "Http notification test";
$from = "<from@from.ru>";
$to = "<to@to.ru>";
$subject = "http notification test";
// здесь мы передаем все POST-параметры http-нотификации в переменную $body
$body = var_export($_POST, true);
// Данные для отправки по email
$host = "host.ru";
$port = "25";
$username = "username";
$password = "userpassword";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
// Если вам не нужны все параметры ($body), то вы можете отправить только operation_id:
// $mail = $smtp->send($to, $headers, $_POST['operation_id']);
// Проверка успешности отправки сообщения
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment