fork download
  1. <?php
  2. echo "kod";
  3.  
  4. // Функция для выполнения POST-запроса к 1с
  5. function makePostRequestTo1c($url, $username, $pass, $data)
  6. {
  7. $data_string = json_encode($data);
  8. $ch = curl_init($url);
  9.  
  10. curl_setopt($ch, CURLOPT_POST, 1);
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); // Преобразуем в строку
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13.  
  14. // Авторизация (пример с basic auth)
  15. curl_setopt($ch, CURLOPT_USERPWD, "$username:$pass");
  16. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  17.  
  18. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  19. 'Content-Type: application/json',
  20. 'Content-Length: ' . strlen($data_string)
  21. ));
  22.  
  23. $response = curl_exec($ch);
  24.  
  25. if (curl_errno($ch)) {
  26. echo 'Ошибка cURL: ' . curl_error($ch);
  27. } else {
  28. echo $response;
  29. }
  30.  
  31. curl_close($ch);
  32. }
  33.  
  34. function ykassaWebhook() {
  35. //echo "kod";
  36. //try {
  37.  
  38. //Подставить адрес веб сервиса
  39. $webhookUrl = 'http://87.255.230.51:60080/buh/hs/bitrixpayments/payments';
  40.  
  41. $response = makePostRequestTo1c($webhookUrl, "AnnaV", "1611016110", [
  42. 'id' => '1516516',
  43. 'paid' => 'Оплата',
  44. ]);
  45.  
  46. //} catch (Exception $e) {
  47. // Возвращаем ошибку
  48. // header('HTTP/1.1 400 Something went wrong');
  49. // exit();
  50. //}
  51. }
  52.  
  53. ykassaWebhook();
  54. ?>
  55.  
Success #stdin #stdout 0.04s 25648KB
stdin
Standard input is empty
stdout
kodОшибка cURL: