Advertisement
GigilinE

Untitled

Mar 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. sendPicture($id, "picture.png");
  2.  
  3.  
  4. function sendPicture($_chatID, $file_on_server){
  5.  
  6. $target_url = 'https://api.telegram.org/**<YOUR TOKEN HERE>**/sendphoto';
  7.  
  8. $file_name_with_full_path = realpath('./'.$file_on_server);
  9.  
  10. $post = array(
  11. 'chat_id' => $_chatID,
  12. 'photo' => '@'.$file_name_with_full_path
  13. );
  14.  
  15. $ch = curl_init();
  16. curl_setopt($ch, CURLOPT_URL,$target_url);
  17. curl_setopt($ch, CURLOPT_POST,1);
  18. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  19. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  20. $result=curl_exec ($ch);
  21. curl_close ($ch);
  22. echo $result;
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement