Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Dyron
Wanderer


Joined: 08 Apr 2004
Posts: 99
Location: USA

PostPosted: Sat Sep 24, 2016 4:11 am   

API and IRE
 
I've been trying to figure this out for a few days but haven't gotten any closer. It's just out of my league, apparently.

I want to pull information from a webpage and be able to print it out on my screen.. Here's the documentation I've been working off of:
http://www.ironrealms.com/IREAPIdocumentation.pdf
ttp://www.imperian.com/game/honors/Imperian/Dyron
http://forums.imperian.com/discussion/262/player-list

I'm really not sure how to go about it. All I really want is the players Name, Level, and Profession and be able to print it to the screen.

Anyone able to get me headed the right way or in all honesty just show me how to do it?
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Sat Oct 01, 2016 3:42 pm   
 
http://forums.zuggsoft.com/forums/viewtopic.php?t=12115
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Sat Oct 08, 2016 2:42 am   
 
Notice the use of ~ in #script to bypass the typical zscript syntax

#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)
Reply with quote
Dyron
Wanderer


Joined: 08 Apr 2004
Posts: 99
Location: USA

PostPosted: Mon Oct 10, 2016 3:44 am   
 
Thanks, Edogg.. I'm working on the last bit but you almost got me there.

#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters/dyron.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)

Currently, trying to figure out how to make it so I can do an alias pull to change the characters name, like whois dyron would do http://api.imperian.com/characters/dyron.json

Then going to take that and be able to print something like Dyron(Outrider): Level 106 - Antioch
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Wed Nov 09, 2016 3:33 am   
 
Sorry Dyron been plenty busy,
As for the alias just create one named whois then put the additional line #var player %1 (player can be whatever you want to label it), then replace the name in the hyperlink with @player:

#var player %1
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http://api.imperian.com/characters/@player.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)


<alias name="whois" id="2457">
<value>#var player %1
#script {strHTML = ~"~"}
#script {Sub getHTML:Set objHTTP = CreateObject~(~"MSXML2.ServerXMLHTTP~"):objHTTP.Open ~"GET~", ~"http:~/~/api.imperian.com~/characters/@player.json?%time( hhnnss)~", ~"FALSE~":objHTTP.Send:strHTML = objHTTP.ResponseText:Set objHTTP = Nothing:End Sub}
#mss {getHTML}
#show %mss( strHTML)
</value>
</alias>

you could even make the actually hyperlink a variable like so:
#var hyperlink http://api.imperian.com/characters/@player.json
then replace the code: objHTTP.Open ~"GET~", ~"http:~/~/api.imperian.com~/characters/@player.json?%time( hhnnss)~" with
objHTTP.Open ~"GET~", @hyperlink?%time( hhnnss)~"

As for pulling only some data out of this you could use triggers and gag it, when I get more time I can come up with a better solution
Reply with quote
Dyron
Wanderer


Joined: 08 Apr 2004
Posts: 99
Location: USA

PostPosted: Wed Nov 09, 2016 3:48 am   
 
Thanks, Edogg..
Honestly, I had given up on it. Never could get anywhere.. Currently, I just do a whois and it pulls up the webpage direct.. Slower than I want but as much as I could get.

I just tried what you did and stored it in a variable but it stores all of it as one line.. Was really hoping it might give me a pull like gmcp. Going to try to fiddle with what you gave me a bit more..

As I said, thanks a ton.
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Sun Dec 04, 2016 3:14 am   
 
this works but is not the best, sorry I really don't know lua:
make an alias called whois
then put this in the body:
#var player %1
#var hyperlink "http://api.imperian.com/characters/"@player".json"
#lua {if not http then http = require("socket.http") end
local page = http.request(~"@hyperlink~")
wstart = string.find(page, "fullname", 0, true)
wend = string.find(page, "bashing_level", 0, true)
where = string.sub(page, wstart, wend - 1)
zs.print("\n")
zs.print("\027[1;37m"..where)
}

You should be able to type whois name
it will fail if the player name does not exist
this worked for me: http://postimg.org/image/tfsqhg50f/49313512/
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net