Hi
Maybe it's a dumb question, but can i use the API through mIRC and a msl Script?
Until now i got data from tvrage, imdb, google etc via http-sockets.
How do i use the API with Sockets? Sorry I´m not really into it.
thx for answers
Yes, you can use it. Pretty much it's the same as for any other api/parser. You just need to supply url which you check and then manipulate received data in ways you want.
Example: http://forums.mirc.com/ubbthreads.php/topics/240022/Re:_Simple_Socket_Script#Post240022
Thx, i know how to use sockets, that´s not the problem. But good to know that it´s possible.
I wrote a script already, searches google for the tvmaze link and reads out the www.tvmaze.com/show/... url, but it doesn´t give the information cause of php or something.
And i've tried to get information over api.tvmaze.com, but doesn´t work, like:
alias dtgettvmaze {
sockclose dtvmaze
sockopen dtvmaze api.tvmaze.com 80
}
on *:sockopen:dtvmaze:{
sockwrite -n $sockname GET /singlesearch/shows?q= $+ $1 HTTP/1.1
sockwrite -n $sockname Host: api.tvmaze.com $+ $crlf $+ $crlf
}
This returns not very much :/
HTTP/1.1 404 Not Found
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 16 Aug 2016 21:23:55 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.5.9-1ubuntu4.17
Access-Control-Allow-Origin: *
Cache-Control: public, max-age=3600
0
0 is more like...nothing? With the api i could search directly with tvmaze, would be the sh.t!
could anybody tell me how i do the requests right?
First of all, change the alias to the same as the rest of it.
As for the error, I'm not sure how to actually do it, but it's to do with this part:
sockwrite -n $sockname GET /singlesearch/shows?q= $+ $1 HTTP/1.1
Doesn't seem as if the parameter is actually being added; http://api.tvmaze.com/singlesearch/shows?q= by itself gives a 404 error (look in Google's developer console).
After I added on *:sockread: and echo'd it out, I found that if I hardcoded it in, i.e GET /singlesearch/shows?q=test then it would work.
thanks for answer!
what about the alias? the alias is unneccessary, can be named after everything, or what do you mean?
i thought that too, but it doesn´t help. i tried to put the name in the script too, like you wrote.
a complete link just to get a result, but doesn´t work.
so you got a result?
the $+ $1 should also work, cause it is replaced with data before it is send, couldn't also be the problem...that would be too simple.
im writing scripts like over 15 years...but im using always the same syntax for http socket requests, this time is doesn´t work.
the output is plain text which is normally interpreted by a browser, but plain text like it is with socket requests...i don't understand.
sry for my english, im german
Okay, I've still got no idea why, but $1 is empty. Here's an alternative (and working solution) using a popup box.
alias dtgettvmaze {
set %show = $input(Enter Show, e)
sockclose dtvmaze
sockopen dtvmaze api.tvmaze.com 80
}
on *:sockopen:dtvmaze:{
sockwrite -n $sockname GET /singlesearch/shows?q= %show HTTP/1.1
sockwrite -n $sockname Host: api.tvmaze.com $+ $crlf $+ $crlf
}
on *:sockread:dtvmaze: {
if ($sockerr > 0) {
echo -a Error.
halt
}
else {
var %temp
sockread %temp
echo -a %temp $crlf
}
}
ah very nice. big thx! :)
ok, then it can't be a identifier, it has to be a variable.
but i have tested it even with the whole link in the script. strange..