mIRC Home    About    Download    Register    News    Help

Print Thread
#259196 15/10/16 08:33 AM
Joined: May 2016
Posts: 50
T
Babel fish
OP Offline
Babel fish
T
Joined: May 2016
Posts: 50
So with the recent change to the Twitch API where we have to give a client id in the url to get access, how does one achieve this? I tried the following code, with no luck.
Code:
on $*:TEXT:!json:#:{
  JSONOpen -ud test https://api.twitch.tv/kraken/streams/streamname
  JSONUrlHeader {test} {client_id} {MYCLIENTID}
  var %result = $json(test,_id)

  if (%result) {
    msg # Status: %result
  } 
  else {
    msg # Status: %result
  }

}


The new url for Twitch API request is as follows:
https://api.twitch.tv/kraken/streams/twitchuser?client_id=MYCLIENTID


Any help would be appreciated, thanks


Life is potato.
Joined: Jun 2015
Posts: 84
F
Babel fish
Offline
Babel fish
F
Joined: Jun 2015
Posts: 84
Here's an example using the stuff to grab uptime.

Code:
alias startTime {
  var %j = streamUptime
  JSONOpen -duw %j https://api.twitch.tv/kraken/streams/ $+ $1 $+ ?= $+ $ticks
  JSONUrlMethod %j GET
  JSONUrlHeader %j Client-ID: %clientID
  JSONUrlGet %j
  var %uptime = $ctime($replace($json(%j,stream,created_at),T,$chr(32),Z,))
  return %uptime
}


Link Copied to Clipboard