Advertisement
falconaut

Telegram Notificatio using cURL

Jul 30th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. function post_to_url($url, $data) {
  3.    $fields = '';
  4.    foreach($data as $key => $value) {
  5.       $fields .= $key . '=' . $value . '&';
  6.    }
  7.    rtrim($fields, '&');
  8.  
  9.    $post = curl_init();
  10.  
  11.    curl_setopt($post, CURLOPT_URL, $url);
  12.    curl_setopt($post, CURLOPT_POST, count($data));
  13.    curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
  14.    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
  15.  
  16.    $result = curl_exec($post);
  17.  
  18.    curl_close($post);
  19. }
  20.  
  21. $data = array(
  22.    "apiHash" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  23.    "phoneNumber" => "123456789",
  24.    "message" => "Testing Telegram Notificatio"
  25. );
  26.  
  27. post_to_url("http://www.api.notificatio.me/v1/user/message", $data);
  28.  
  29. echo "Success !";
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement