mIRC Home    About    Download    Register    News    Help

Print Thread
#252998 20/05/15 02:50 PM
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Hey everyone!

I am looking to get some help, I can't figure out why JSON isn't parsing / outputting data from a socket that connects to twitch.

I've followed this thread here: https://forums.mirc.com/ubbthreads.php/topics/245984/!status_and_!game_possible?_%5BT

and i am able to set the topic and the game successfully. The problem I believe is JSON, when the echo is displayed, i get: "status set: " or "status: ".

In the config, if (* 200 OK iswm $read(%header,1)) msg %chan Status set: $json(%data,status), I think the problem is $json(%data,status) is either empty or nothing was parsed.

Any ideas?

Thanks!


twitter @keyeslol
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Check the content of the file before deleting it

Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
EDIT:

OKay so, it's not json itself, it has to be something else.

I created the following check:

alias check {
JSONOpen -du test https://api.twitch.tv/kraken/channels/<channelname>
echo -a $json(test,status)
}

It echo's the correct data.

Last edited by keyeslol; 20/05/15 05:13 PM.

twitter @keyeslol
Joined: Jun 2015
Posts: 5
G
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2015
Posts: 5
same here .... no matter what i do i cant get the phraser to work. i tried saving the code to a external file and load it, putting it in the remote file...
the code i use: http://hawkee.com/snippet/10194/

the link to a phraser that loki posted a while ago (http://www.mircscripts.org/comments.php?cid=4407) seems to be broken

Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249
This version returns nothing if specified channel doesnt exist. If exists - all is ok.


Dont give a fish - teach to fish!
Joined: May 2015
Posts: 249
Fjord artisan
Offline
Fjord artisan
Joined: May 2015
Posts: 249


Dont give a fish - teach to fish!
Joined: Jun 2015
Posts: 5
G
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2015
Posts: 5
do you have the json script that loki posted a while ago? if so could you repost it somewhere, please?

Joined: Jun 2015
Posts: 5
G
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2015
Posts: 5
well i do get the infos from twitch but the json wont get prased
Code:
{"mature":false,"status":"statusTest","display_name":"GenUltra758","game":"The Forest","_id":47491346,"name":"genultra758","created_at":"2013-08-12T09:31:07Z","updated_at":"2015-06-11T15:14:34Z","logo":"http://static-cdn.jtvnw.net/jtv_user_pictures/genultra758-profile_image-aa38dfa319629acc-300x300.png","banner":null,"video_banner":"http://static-cdn.jtvnw.net/jtv_user_pictures/genultra758-channel_offline_image-274f02276ca7b4f4-640x360.png","background":null,"url":"http://www.twitch.tv/genultra758","_links":{"self":"https://api.twitch.tv/kraken/channels/genultra758","follows":"https://api.twitch.tv/kraken/channels/genultra758/follows","commercial":"https://api.twitch.tv/kraken/channels/genultra758/commercial","stream_key":"https://api.twitch.tv/kraken/channels/genultra758/stream_key","chat":"https://api.twitch.tv/kraken/chat/genultra758","features":"https://api.twitch.tv/kraken/channels/genultra758/features","subscriptions":"https://api.twitch.tv/kraken/channels/genultra758/subscriptions","editors":"https://api.twitch.tv/kraken/channels/genultra758/editors","videos":"https://api.twitch.tv/kraken/channels/genultra758/videos"},"teams":[]}

Joined: Jun 2015
Posts: 5
G
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2015
Posts: 5
i think it does not work cuz the code i am using was coded for the old phraser...

i fixed it by testing stuff:

Code:
;ORIGINAL CODE:

on *:signal:topic.get:{
  var %err = $1, %sockname = $2, %header = $3, %data = $4
  var %chan = $hget(%sockname,chan)


  if (* 200 OK iswm $read(%header,n,1)) msg %chan Status: $JSON(%data, status)
  else msg %chan Could not get status.

  hfree -w %sockname
  if ($isfile(%header)) .remove %header
  if ($isfile(%data)) .remove %data
}




EDITED CODE:

on *:signal:topic.get:{
  var %err = $1, %sockname = $2, %header = $3, %data = $4
  var %chan = $hget(%sockname,chan)

  jsonopen -fd datafile %data
  if (* 200 OK iswm $read(%header,n,1)) msg %chan Status: $json(datafile, status)
  else msg %chan Could not get status.

  hfree -w %sockname
  if ($isfile(%header)) .remove %header
  if ($isfile(%data)) .remove %data
}

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
This is the original parser used in that thread: http://pastebin.com/VSe6AiQq

This one is actively maintained: http://hawkee.com/snippet/10194/ but uses slightly different calls.

Joined: Jun 2015
Posts: 5
G
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
G
Joined: Jun 2015
Posts: 5
even if i use the original phraser i still get "Status:" without the status/stream title

Last edited by GeneralUltra758; 11/06/15 03:57 PM.
Joined: May 2015
Posts: 133
K
Vogon poet
OP Offline
Vogon poet
K
Joined: May 2015
Posts: 133
Did you ever figure this out? I haven't come back to this in a while.


twitter @keyeslol

Link Copied to Clipboard