Skip to content

Instantly share code, notes, and snippets.

@shift-reality
Created February 23, 2021 17:40
Show Gist options
  • Save shift-reality/ca56329d0875f15c9159fa449d63f06f to your computer and use it in GitHub Desktop.
Save shift-reality/ca56329d0875f15c9159fa449d63f06f to your computer and use it in GitHub Desktop.
<?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