Yahoo weather and basic HTTP ?'s
def90
Posts: 14
I'm trying to set up my own Weather module and learn a little bit about HTTP programming at the same time. So far I am trying to use the following sites:
http://xoap.weather.com/weather/local/80301?cc=*&dayf=10
http://weather.yahooapis.com/forecastrss?p=80301
Basically I am tacking online/offline with a variable and sending an IP_Client_Open command if needed, then a GET command. I have tried various strings with the GET command and can't seem to get any incommin strings from the web sites.
For reference:
http://developer.yahoo.com/weather/
If I am using http://weather.yahooapis.com/forecastrss?p=80301 I am thinking weather.yahooapis.com should be in the IP_CLIENT_OPEN command and the GET string should be: /forecastrss?p=80301 I have also tried weather.yahooapis.com/forecastrss?p=80301 for the GET string..
I have tried many variations of:
IF(CONNECTED=0) IP_CLIENT_OPEN(dvIP_WEATHER.Port,'http://weather.yahooapis.com',80,1)
WAIT_UNTIL(CONNECTED=1){
SEND_STRING dvIP_WEATHER,"
'GET /forecastrss?p=80301 HTTP/1.1',13,10,
'HOST: http://weather.yahooapis.com',13,10,
13,10"}
I have tried it with and without the extra HTTP/1.1 and Host parameters as well.
Does anyone have any good lay person reading on the HTTP and HOST portions of the GET command syntax or a basic explanation of what is needed for this and why?
Thanks..
http://xoap.weather.com/weather/local/80301?cc=*&dayf=10
http://weather.yahooapis.com/forecastrss?p=80301
Basically I am tacking online/offline with a variable and sending an IP_Client_Open command if needed, then a GET command. I have tried various strings with the GET command and can't seem to get any incommin strings from the web sites.
For reference:
http://developer.yahoo.com/weather/
If I am using http://weather.yahooapis.com/forecastrss?p=80301 I am thinking weather.yahooapis.com should be in the IP_CLIENT_OPEN command and the GET string should be: /forecastrss?p=80301 I have also tried weather.yahooapis.com/forecastrss?p=80301 for the GET string..
I have tried many variations of:
IF(CONNECTED=0) IP_CLIENT_OPEN(dvIP_WEATHER.Port,'http://weather.yahooapis.com',80,1)
WAIT_UNTIL(CONNECTED=1){
SEND_STRING dvIP_WEATHER,"
'GET /forecastrss?p=80301 HTTP/1.1',13,10,
'HOST: http://weather.yahooapis.com',13,10,
13,10"}
I have tried it with and without the extra HTTP/1.1 and Host parameters as well.
Does anyone have any good lay person reading on the HTTP and HOST portions of the GET command syntax or a basic explanation of what is needed for this and why?
Thanks..
0
Comments
http://www.w3.org/
Here is a link to the HTTP standard:
http://www.w3.org/Protocols/rfc2616/rfc2616.html
HOST: should not include the http:// prefix
HTH
It will show you what your pc is sending/receiving over the lan cable so you will be able to see exactly how your requests are being handled.
It can be a bit daunting so you may prefer the easier to read LiveHTTPHeaders plugin for firefox.
http://livehttpheaders.mozdev.org/
using your example of sending a GET request to http://weather.yahooapis.com/forecastrss?p=80301 I can see that my browser is sending the data
Here's a link to a recent post that has a module that uses HTTP that you can use as an aid or reference.
http://www.amxforums.com/showthread.php?p=25830#post25830
Read the references that Joe suggested and filpee's suggestion to use WireShark is a must to determine the dialogue that is required. It allows you to see what you need to send and let's you see what you should recieve when you connect from your PC.
I think I allready have a copy of what you posted here.. But what fun would that be? I find that I retain and understand this stuff alot better if I struggle through something and figure it out rather than cut and paste..
I did come up with a program that updates a DYNDNS account through dyndns.org using some tips I picked up here and tried converting what I was doing with that to the weather sites with no luck..
filpee, I'll check out the tools you linked too..
Paul
I agree completely but people are asking for it. They are asking for yahoo, apple and google style widgets for their touchscreens and until AMX has a built in browser or easy way to do it I have to come up with something.. People are even showing me pictures of ads for Savant wondering why their panels can't do this, I of course let them know that Savant is complete vaporware but that is beside the point. People have it on their computers and phones and they want it on their panels..
Paul
You all must have more tech savy clients . . . ours just want stuff to turn on and off. *sigh*
Our clients love those kinds of things. My most favorite features: Weather, Multi-zone kitchen timer, mini-emailer,
I actually get my weather feed via telnet from weatherunderground. We also have several cleints who paid for the AMX i!-Weather.
So I switched to the Weatherbug feed. They have a published API ... though it's not entirely complete nor entirely accurate. They don't give as much data as RSSWeather, but neither do they have the restrictions. I have a working module that was loosely built off Vining's, including a "lite" interface for such devices as the R4, where you can strip off what you don't need. I don't have it in much of a form that could be easily shared right now, but if people are interested, I can put something together.
That's a great find, I don't know why my searches weren't picking up that site.. Just downloaded the API, looks simple, what is not accurate about it? Thanks..
Some of the parameters to the GET command are completely ignored, and others, if you include them, will cause the whole thing to return data from Arlington VA ... no matter what you were really asking for. My workaround was to only submit a zip code for US locations. For international stations, just the country code (and you have to use theirs, which are decidedly non-standard) and city name. In all cases, the actual local station you get will be the closest match to what area you asked for with the most current data ... and it may change on a day to day basis.
I figured out my initial problem of not receiving info back from the web, I was using port 1 (0:1:0) and managed to look at it for hours before my brain told me that was the problem..
Do you guys prefer specifying a port or using the First_Local_Port command?
Jeff
from NETLINX.axi (C:\Program Files\Common Files\AMXShare\AXIs)
DEFINE_CONSTANT
(*-- NetLinx.axi version
*)
CHAR NETLINX_AXI_VERSION[6] = '1.42'
(*-- URL Constants
*)
CHAR URL_Flg_TCP = 1; // TCP connection
CHAR URL_Flg_AcctInfoPresent = $02; // Added v1.21 - If set, the User and Password fields are valid
CHAR URL_Flg_Temp = $10; // Temp Connection
CHAR URL_Flg_Stat_PrgNetLinx = $20; // URL set by NetLinx Set_URL_List
CHAR URL_Flg_Stat_Mask = $C0; // status mask upper 2 bits
CHAR URL_Flg_Stat_Lookup = $00; // Looking up IP
CHAR URL_Flg_Stat_Connecting = $40; // connecting
CHAR URL_Flg_Stat_Waiting = $80; // waiting
CHAR URL_Flg_Stat_Connected = $C0; // connected
(*-- IP Address Flag Constants
*)
CHAR IP_Addr_Flg_DHCP = 1; // Use DHCP
(*-- for user
*)
INTEGER FIRST_VIRTUAL_DEVICE = 32768;
INTEGER FIRST_LOCAL_PORT = 2;
I was just wondering if there was any advantage to using it, I seem to remember having a problem with a module that used this once until I set it to a specific port..
FIRST_LOCAL_PORT is a constant defined in NETLINX.axi and has no use what so ever. Forget it even exists.
So, no there is no advantage. I use numbers only and define all devices in one location in my main file and use multuple DEFINE_DEVICE sections to keep it organized and easily searched. I'll then reference these device in .axi files where I pass them to modules or what ever.