Get string from web through dot net


#1

Hello, I’m trying to get a simple sting via PHP to maxscript. If you goto https://www.squirrel-02.com/Con/Get_Version.php you should get a simple page with a sting of “1.10”.

I’m sort of list on this. What do I need to do to fetch this data?


ConNet = ((dotnetClass "System.Net.WebRequest").Create "https://www.squirrel-02.com/_Con_/Get_Version.php").GetResponse()
response=ConNet.GetResponse()
sysNet.dispose()


#2

looks like this works but I don’t like this way…


FN Get_Ver = (
   if internet.CheckConnection url:"https://www.squirrel-02.com" force:true == true then(
      timeouts=1000 
      rollout httpSock "httpSock" width:0 height:0 (activeXControl port "MSXML2.ServerXMLHTTP" setupEvents:false releaseOnClose:false);
      createDialog httpSock pos:[-100,-100];destroyDialog httpSock;   
      gethttp=httpSock.port   
      httpSock=undefined   
      gethttp.SetTimeouts timeouts timeouts timeouts timeouts
      gethttp.open "GET" "https://www.squirrel-02.com/_Con_/Get_Version.php" false
      gethttp.send();   
      return gethttp.responseText 
   )
   else(
      return "0.0"
   )
)
Ver = Get_Ver()


#3

request = (dotnetClass "System.Net.WebRequest").Create "https://www.squirrel-02.com/_Con_/Get_Version.php"
response = request.GetResponse()
dataStream = response.GetResponseStream()
reader = dotnetobject "System.IO.StreamReader" dataStream
data = reader.ReadToEnd()

maybe ?


#4

Oh!!!
the better one:


client = dotnetobject "System.Net.WebClient"
client.DownloadString "https://www.squirrel-02.com/_Con_/Get_Version.php"


#5

the bigger problem is to check that url exists, valid, and you can connect to it


#6

Thanks!

This should check if you have internet and URL from…

internet.CheckConnection url:“https://www.squirrel-02.com” force:true == true

or am I wrong about this function