Bot Api Version

Bot Api Version
This commit is contained in:
Denny Dai
2015-06-29 22:13:58 +08:00
parent 1ab6510772
commit e321324785
5 changed files with 46 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace DBot;
class Base
{
public function exec($command, $data = null)
{
$context = array();
if (is_array($data))
{
$opts = array (
'http' => array (
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded",
'content' => http_build_query($data)
)
);
$context = stream_context_create($opts);
}
return file_get_contents(TB_API_URL.$command, false, $context);
}
public function msg($id, $msg)
{
return $this->exec('sendMessage', array('chat_id' => $id, 'text' => $msg));
}
}