authToken($client_id, $client_secret, $grant_type); $config = Telstra_Messaging\Configuration::getDefaultConfiguration()->setAccessToken($result['access_token']); $apiInstance = new Telstra_Messaging\Api\MessagingApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $mqtt = new phpMQTT($server, $port, $mqtt_id); $data = file_get_contents('php://input'); $data = json_decode($data, true); if($data['messageId']){ $arr = explode(' ',trim($data['body'])); if(strtolower($arr[0])=="lights"){ if ($mqtt->connect(true, NULL, $username, $password)) { $mqtt->publish("lights", strtolower($arr[1]), 0); $mqtt->close(); } else { echo "Time out!\n"; } } elseif(strtolower($arr[0])=="safe"){ if ($mqtt->connect(true, NULL, $username, $password)) { $mqtt->publish("safe", strtolower($arr[1]), 0); $mqtt->close(); } else { echo "Time out!\n"; } } } if(isset($data['from'])){ $arr = array('to' => $data['from'], 'body' => $arr[1].' added to the iot broker for '.$arr[0]); $payload = new \Telstra_Messaging\Model\SendSMSRequest($arr); $result = $apiInstance->sendSMS($payload); print_r($result); } ?>