Writing a generic plugin | ThingSpeak Apps | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Writing a generic plugin
No permission to create posts
July 16, 2014
3:19 pm
Avatar
Resseguie
New Member
Members
Forum Posts: 2
Member Since:
July 16, 2014
sp_UserOfflineSmall Offline

I'm interested in writing a generic / reusable plugin for Thingspeak. But all the examples I've seen are hard coded to call the API with a specific channel ID (and API_KEY if required) to get the feed data. Is there a way for the plugin to get the "current" channel who's page it's installed on?

July 16, 2014
4:05 pm
Avatar
lee

Admin
Forum Posts: 457
Member Since:
March 14, 2011
sp_UserOfflineSmall Offline

Hi,

I just wrote a simple plugin that should allow you to get the channel ID depending on the channel page it exists on: https://thingspeak.com/plugins/4482 . Just view-source, and you should see the JavaScript code that should help you out.

lee

July 17, 2014
2:23 pm
Avatar
Resseguie
New Member
Members
Forum Posts: 2
Member Since:
July 16, 2014
sp_UserOfflineSmall Offline

Makes sense, thanks. Any thoughts on private channels that would require an API key?

July 17, 2014
2:33 pm
Avatar
lee

Admin
Forum Posts: 457
Member Since:
March 14, 2011
sp_UserOfflineSmall Offline

It's a little more complicated, but you could extract the API keys from a JSON list of your channels. Please see "List My Channels" under the documentation here: https://thingspeak.com/docs/channels#index .

lee

August 20, 2018
7:36 am
Avatar
Spreeuw
New Member
Members
Forum Posts: 1
Member Since:
August 20, 2018
sp_UserOfflineSmall Offline

This is indeed possible by using that channel API call, although it only works for the plugins when the are embedded in the channel page (iframe). When you detach the plugin to display it into a separate window/tab, it doesn't have any reference to the channel anymore, so you'd need a fallback channel + api key. Here's an example.

You can get your User API key from Account > Profile (https://thingspeak.com/account/profile).

code here: https://pastebin.com/ikSCch3k

(couldn't find any way to post code to this forum without losing formatting)

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

qkpham, SANGAMNATH B, swatiiot, kalyanigaware16@gmail.com, Romi, Drakan01

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457