Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var user_api_key = "YOUR_USER_API_KEY";
- var channel_id = 123456; // fallback channel ID
- var read_api_key = 'YOUR_CHANNEL_READ_API_KEY';
- if (window.parent) {
- var channel_id = window.parent.channel.channel.id;
- $.ajax({
- url: "https://api.thingspeak.com/channels.json",
- dataType: 'json',
- async: false,
- data: { 'api_key': user_api_key },
- success: function(data) {
- if (data) {
- $.each( data, function( key, channel ) {
- if (channel.id == channel_id) {
- $.each( channel.api_keys, function( key, api_key_data ) {
- if (api_key_data.write_flag == false) {
- read_api_key = api_key_data.api_key;
- return false; // break out of loop
- }
- });
- }
- });
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement