Skip to content

Instantly share code, notes, and snippets.

View itskenny0's full-sized avatar

kenny itskenny0

  • I don't know what I'm doing, Inc.
  • Germany
View GitHub Profile
@itskenny0
itskenny0 / Telegram.class.php
Created October 18, 2016 12:43
Tiny, incomplete, hacky Telegram bot API class
<?php
class Telegram {
const API_ROOT = "https://api.telegram.org/bot%KEY%/%METHOD%";
private $botkey;
private $methods = [
"getUpdates" => [
"meta" => [
"type" => "POST"
],
@itskenny0
itskenny0 / tiny-telegram-reply-bot.php
Last active August 22, 2016 19:32
Possibly the tiniest 'Hello World' webhook bot you can write in PHP without any libraries.
<?php
$chat = json_decode(file_get_contents("php://input"))->message->chat->id;
header("Content-Type: application/json");
echo json_encode(array("method" => "sendMessage", "text" => "Hello World", "chat_id" => $chat));
@itskenny0
itskenny0 / witai_speech.php
Created August 19, 2016 08:10
wit.ai speech recognition in PHP
<?php
/* wit.ai speech recognition in PHP */
$request = curl_init('https://api.wit.ai/speech');
$headers[] = 'Authorization: Bearer YOURAPIKEY';
$headers[] = 'Content-Type: audio/wav';
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($request, CURLOPT_POSTFIELDS, file_get_contents("soundfile.wav"));
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
<?php
/**
* FileServe
*
* Class that serves a file from disk to a client.
*
* @package FileServe
* @author Kenny <[email protected]>
* @license The Unlicense (http://unlicense.org)
*/