Created
February 23, 2021 17:40
-
-
Save shift-reality/ca56329d0875f15c9159fa449d63f06f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MarketBot { | |
function __construct(array $target, $timeout = 5) { | |
$this->target = $target; | |
$this->timeout = $timeout; | |
} | |
function send($message) { | |
$payload = [ | |
'usr' => $this->target['usr'], | |
'pw' => $this->target['pw'], | |
'botid' => intval($this->target['botid']), | |
'messages' => [ | |
[ | |
'program' => $this->target['program'], | |
'chat' => $this->target['chat'], | |
'type' => 'text', | |
'_text' => $message, | |
], | |
], | |
]; | |
$ch = curl_init('https://marketbot.biz/index.php/' | |
. 'botapi/send_message'); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); | |
curl_exec($ch); | |
curl_close($ch); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment