Getting Data from Website

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Getting Data from Website

Post by GSPearson » Wed Mar 25, 2015 6:33 pm

I have a function that goes out to a website to acquire the data as a method to check if the application has access to the internet

Code: Select all

function CheckInternetConnection
   local lURL, lconnCheck
   switch (the platform)
      case "Win32"
         put "http://www.yourcfpro.com" into lURL
         put URL lURL into lconnCheck
         if lconnCheck is empty then 
            return "No Data from Website"
         else
            return "Received Website Data"
         end if
         break
      default
         answer "This application cannot run on the " && the platform && " platform."
         break
   end switch
   
   delete variable it
   delete variable lURL
   delete variable lconnCheck
end CheckInternetConnection
But for some reason when I run my application I get the response No Data Received as lconnCheck is empty. If I pull up a web browser and goto the same URL I get the webpage. Using Livecode 7.0.3 at the moment. I have even changed the URL as it used to be www.google.com and I thought that google did something between yesterday and today as it worked yesterday but not today. Then when I added this other website and ran the application I got the same result so simply pulling my hair out as to why it is not working like it did just less than 12 hours ago.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Getting Data from Website

Post by sefrojones » Wed Mar 25, 2015 7:22 pm

This worked for me in LiveCode 7.03 running on Ubuntu.

Code: Select all

function CheckInternetConnection
   put URL "http://www.yourcfpro.com" into  lconnCheck
   if lconnCheck is empty then 
      return "No Data from Website"
   else
      return "Received Website Data"
   end if
end checkinternetconnection
--Sefro

EDIT: this is also working in LiveCode 7.03 running on Windows 7 Ultimate 64 bit

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: Getting Data from Website

Post by GSPearson » Thu Mar 26, 2015 12:40 pm

I know this works under Livecode 7.0.3 cause I have been using it since the start of the Create It With Livecode Course I have been going through to enhance my knowledge and learn form the experts of this software. I just do not know or understand why it stopped working yesterday and does not work today. I have restarted my computer multiple times and no other changes have been done to this machine.

Even if I put the line into the message box, I do not get anything in the variable. But if I do other commands in the mesage box and change variables I see it. It has to do something with the URL.



I think it has something to to with Livecode. If I run the revChat application I get errors that it can not connect to the server. I even tried revOnline to get sample stacks and got the same error message about not being able to connect to the server. I know I have internet access cause I am entering this message into the forums.

GSPearson
Posts: 64
Joined: Tue May 10, 2011 7:39 pm

Re: Getting Data from Website

Post by GSPearson » Thu Mar 26, 2015 1:16 pm

Solved this:

I am not sure how to submit this but will explain what was going in here. If someone can point me to the right direction as this might be a bug.


On Tuesday I was at a local school district helping them with their network, website proxy etc. When at the school I entered proxy settings inside of chrome to be able to surf the internet. When I got done, I unchecked the box about using the proxy settings and worked from the office on Wednesday. I updated one of the application I was working on for the Create It with Livecode course and trying to run the application produced the error of not being able to view website. I checked all of my settings and from my office without a proxy I was able to view websites. This went on all day and this morning (Thursday) I tried other livecode applications that releid on the internet and got the same result. No Internet Access. So I knew it was just my machine.

I then cleared out cache as I thought that it might be the result, same result No Internet Access. I even tried over versions of Livecode same result. I even verified that the Proxy settings were turned off which they were. I even tried other browsers and got to websites without any issue.

What happened is even though the proxy was turned off, if Livecode sees a value in the proxy settings it will try and use it no matter if the settings are turned off or not. Once I removed the IP Address and Port from the Proxy settings livecode then was able to view a webpage. I would thing that livecode should see if the checkbox is selected and then if it is use the proxy settings otherwise do not use the proxy settings.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5226
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Getting Data from Website

Post by jacque » Thu Mar 26, 2015 5:02 pm

You might want to submit that as a bug. I'm glad you were able to figure out the problem though.

By the way, you don't need to delete the variables at the end of the handler. LiveCode does all that cleanup for you automatically which saves a great deal of coding. Unless they are script locals or globals, variables created inside the handler are destroyed when the handler ends.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Internet”