Chompil

Villager
Member
Joined
Oct 15, 2013
Messages
23
Reaction score
8
First Language
Hebrew
Primarily Uses
Recently found this script, supposed to allow sending web requests (GET/POST)
and fits RGSS, RGSS2, RGSS3.
anyone familiar with it?

original topic at RPGMakerWeb

I can't get it to work though. feels like something silly, as it's supposed to work,
and it's a simple GET request.
here's my code:
Ruby:
host = "http://www.webcode.me"
path = "/index.html/"
result = EFE.request(host, path)
p result
I just get an empty response (with two dashes). no errors.
the example in the demo does use php pages, but I doubt it matters.
here's a sample code from the demo, if that helps:
Ruby:
host = "www.rpgmakervxace.net"
path = "/forum/login.php"
post = "username=kfdsfdsl&password=24324234"
res = EFE.request(host, path, post, 80)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,947
Reaction score
5,856
First Language
Dutch
Primarily Uses
RMXP

I've moved this thread to RGSS Script Support. Thank you.

 

rexie09

Villager
Member
Joined
Apr 4, 2021
Messages
26
Reaction score
10
First Language
English
Primarily Uses
RMMZ
Recently found this script, supposed to allow sending web requests (GET/POST)
and fits RGSS, RGSS2, RGSS3.
anyone familiar with it?

original topic at RPGMakerWeb

I can't get it to work though. feels like something silly, as it's supposed to work,
and it's a simple GET request.
here's my code:
Ruby:
host = "http://www.webcode.me"
path = "/index.html/"
result = EFE.request(host, path)
p result
I just get an empty response (with two dashes). no errors.
the example in the demo does use php pages, but I doubt it matters.
here's a sample code from the demo, if that helps:
Ruby:
host = "www.rpgmakervxace.net"
path = "/forum/login.php"
post = "username=kfdsfdsl&password=24324234"
res = EFE.request(host, path, post, 80)
without looking at it it may be because the response is suposed to return a JSON and the sites you're trying to access dont return a JSON response.
 
Last edited:

Chompil

Villager
Member
Joined
Oct 15, 2013
Messages
23
Reaction score
8
First Language
Hebrew
Primarily Uses
thanks, I'll try something which returns JSON
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
758
Reaction score
372
First Language
PT-BR
Primarily Uses
RM2k3
(...)
Ruby:
host = "http://www.webcode.me"
path = "/index.html/"
result = EFE.request(host, path)
p result
Hello, I know it may be because I never used WebKit via RGSS, but it looks like you are treating the INDEX.HTML file as a folder.
Wouldn't it be more correct to remove the bar?
path = "/index.html"
 

Chompil

Villager
Member
Joined
Oct 15, 2013
Messages
23
Reaction score
8
First Language
Hebrew
Primarily Uses
apparently it was both the '/' and the json. thanks ^^
this code works fine, just for reference
Ruby:
host = "date.jsontest.com"
path = ""
post = "?format=json"
result = EFE.request(host, path, post, 80)
 

Chompil

Villager
Member
Joined
Oct 15, 2013
Messages
23
Reaction score
8
First Language
Hebrew
Primarily Uses
so.. I accidentally deleted it. *facepalm*
can someone with VX Ace please open this demo & copy the script in it?
my VX trial ended..

never mind. found it. posting here, if anyone needs it
(works for both VX Ace & RPG Maker XP)

Ruby:
module EFE
 
  # I took this method from Gustavo Bicalho's WebKit script. Special thanks him.
  def self.to_ws(str)
    str = str.to_s();
    wstr = "";
    for i in 0..str.size
      wstr += str[i,1]+"\0";
    end
    wstr += "\0";
    return wstr;
  end
 
 
 
  #EFES_WINAPI = Win32API.new('ods', 'naber', 'pp', 'p')
  WinHttpOpen = Win32API.new('winhttp','WinHttpOpen',"PIPPI",'I')
  WinHttpConnect = Win32API.new('winhttp','WinHttpConnect',"PPII",'I')
  WinHttpOpenRequest = Win32API.new('winhttp','WinHttpOpenRequest',"PPPPPII",'I')
  WinHttpSendRequest = Win32API.new('winhttp','WinHttpSendRequest',"PIIIIII",'I')
  WinHttpReceiveResponse = Win32API.new('winhttp','WinHttpReceiveResponse',"PP",'I')
  WinHttpQueryDataAvailable = Win32API.new('winhttp', 'WinHttpQueryDataAvailable', "PI", "I")
  WinHttpReadData = Win32API.new('winhttp','WinHttpReadData',"PPIP",'I')
  #WinHttpWriteData = Win32API.new('winhttp','WinHttpWriteData',"PPIP",'I')

  def self.request2(host, path, post="")
    pr = path
    if(post != "")
      pr = pr + "?" + post
    end
    pr = pr.to_s
    a = EFES_WINAPI.call(to_ws(host), to_ws(pr))
    return a
  end
 
  def self.request(host, path, post="",port=80)
    p = path
    if(post != "")
      p = p + "?" + post
    end
    p = p.to_s
    pwszUserAgent = ''
    pwszProxyName = ''
    pwszProxyBypass = ''
    httpOpen = WinHttpOpen.call(pwszUserAgent, 0, pwszProxyName, pwszProxyBypass, 0)
    if httpOpen
      httpConnect = WinHttpConnect.call(httpOpen, to_ws(host), port, 0)
      if httpConnect
        httpOpenR = WinHttpOpenRequest.call(httpConnect, nil, to_ws(p), "", '',0,0)
        if httpOpenR
          httpSendR = WinHttpSendRequest.call(httpOpenR, 0, 0 , 0, 0,0,0)
          if httpSendR
            httpReceiveR = WinHttpReceiveResponse.call(httpOpenR, nil)
            if httpReceiveR
              received = 0
              httpAvailable = WinHttpQueryDataAvailable.call(httpOpenR, received)
              if httpAvailable
                ali = ' '*1024
                n = 0
                httpRead = WinHttpReadData.call(httpOpenR, ali, 1024, o=[n].pack('i!'))
                n=o.unpack('i!')[0]
               
                return ali[0, n]
              else
                msgbox_p("Error about query data available")
              end
            else
              msgbox_p("Error when receiving response")
            end
          else
            msgbox_p("Error when sending request")
          end
           
        else
          msgbox_p("Error when opening request")
        end
         
      else
        msgbox_p("Error when connecting to the host")
      end
       
    else
      msgbox_p("Error when opening connection")
    end
  end
 
  # my edit, this script doesn't exist. maybe in the other scripts in the demo
  def msgbox_p(text)
    p text
  end
 
end
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

I feel the need to inform everyone on the forums NOT to go with Web Hosting Canada for your hosting needs. It is by far the worst customer service and just overall experience I have ever had with hosting and I am Canadian...
BCj
Got another eye surgery monday. Hope I'll recover quick and all's well. A bit tired of surgeries. On a happy note, working on the next chapter of Escalia so hope I can continue soon :)
Celebrating the arrival of autumn in the Northern Hemisphere :)
When doing a map or whatever, kind of wish you could round out some parts.

Forum statistics

Threads
115,362
Messages
1,089,281
Members
150,053
Latest member
sintigoborja
Top