How to subscribe/publish message using talkback app

1 次查看(过去 30 天)
Hi
Is there anyone who can me help with work around example, as to how to publish message using talkback or plugin on client side? I am using native javascript with jquery and have API key sending GET protocol. I want my button to subscribe to that channel i created, please help me by showing an example i am sure can able to do this. My channel have two fields temp and illuminance, both been programmed on IDE Arduno and have button_state that must read from my talkback functionality;
Plugin functionality for my button to read or subscribing my channel;
<html>
<head>
<!--
NOTE: This plugin will not be visible on public views of a channel.
If you intend to make your channel public, consider using the
MATLAB Visualization App to create your visualizations.
-->
%%PLUGIN_CSS%%
%%PLUGIN_JAVASCRIPT%%
</head>
<body>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"><br/>
<div class="col-md-4 text-center">
<button id="singlebutton" name="singlebutton" class="btn btn-primary">IOT-Talk</button>
</div>
</body>
</html>
<script
src="https://code.jquery.com/jquery-3.3.1.js"integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="crossorigin="anonymous"></script>
<script type="text/javascript">
function OPENDOOR() {
$.ajax({
url:"https://api.thingspeak.com/talkbacks/35734/commands?key=MF710NTKMG0E44UG&command_string=OPENDOOR&position=1",
type: 'GET',
success: function(data) {
//called when successful
//console.log(data);
$('#singlebutton').on('click', function (e) {
$('#singlebutton').append(data);
})
}
});
}
</script>

回答(0 个)

社区

更多回答在  ThingSpeak Community

类别

Help CenterFile Exchange 中查找有关 Act on Data 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by