Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MqttClient
- {
- private $server;
- private $port;
- private $user;
- private $password;
- public function __construct($server, $port = 1883, $user = '', $password = '')
- {
- $this->server = $server;
- $this->port = $port;
- $this->user = $user;
- $this->password = $password;
- }
- public function publish($topic, $payload)
- {
- exec(sprintf('mosquitto_pub -h %s -p %d -u %s -P %s -t "%s" -m "%s"', $this->server, $this->port, $this->user, $this->password, $topic, $payload));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement