requilence / integram

Integrate Telegram into your workflow – Trello, Gitlab, Bitbucket and other bots
https://integram.org
GNU General Public License v3.0
1.54k stars 151 forks source link

Horn in telegram #48

Open zhisme opened 7 years ago

zhisme commented 7 years ago

You should write somewhere how to use this Horn in telegram. This bot allows you to pass user messages exactly to telegram. Because it's not definitely clear how to pass objects to text param. Should it be array, or string, or json, or whatever. But after searching for one hour, I found that it should only string and nothing else.

  $data = array("text" => "Hello telegram from github");
  $data_string = json_encode($data);

  $ch = curl_init('$YOUR_HORN_URL');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Content-Type: application/json',
      'Content-Length: ' . strlen($data_string))
  );

  $result = curl_exec($ch);
  curl_close($ch);

However if you will use

  $data = array("text" => ["name" => "george", "surname" => "my"]);
  ...

It will never get to your horn in telegram. But the response for request will be 200, and you will be stopped with this unnecessary debugging.

requilence commented 6 years ago

This bot is supposed to use the Slack-like syntax. BTW I'm agree that the webhook endpoint shouldn't return 200 status in case it was failed to parse the payload. I will improve this thing and reply here after