Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFInvoke CDYNE weather

Participant ,
Jul 26, 2010 Jul 26, 2010

There are 3 methods to use with cdyne:  (1) getcityweatherbyzip  (2) getcityforecastbyzip (3) getWeatherInformation

More information can be found on their site at http://ws.cdyne.com/WeatherWS/Weather.asmx

The first two are pretty straightforward and return the values needed:

<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getcityweatherbyzip" returnvariable="aWeatherReturn">
<cfinvokeargument name="ZIP" value="27502"/>
</cfinvoke>


<cfoutput>
#aweatherreturn.weatherid#<Br />
#aWeatherReturn.temperature#<br />
#aweatherreturn.description#<Br />
#aweatherreturn.weatherstationcity#<br />

</cfoutput>

<cfdump var="#aweatherreturn#">

I am stumped on method 3, getWeatherInformation.  Does anyone know how to get the returned values for weatherid, description, and pictureURL from this method?  I don't get this.  How does it know what area/zip for this method?

<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn">
</cfinvoke>

<cfdump var="#bweatherReturn#">

<cfoutput>#bweatherreturn.weatherdescription#<Br />
</cfoutput>

Here is an example of my results for both methods:

http://shepherdsvineyardpool.com/sites/dsp/dsp_weather.cfm

Thank YOU!  Once this is resolved, I hope to have CDYNE post this example on their website to help others.  They have an example of the other methods, but not this one.

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 27, 2010 Jul 27, 2010

I am stumped on method 3, getWeatherInformation.  Does

anyone know how to get the returned values for weatherid,

description, and pictureURL from this method?  I don't get

this.  How does it know what area/zip for this method?

I do not think it is doing what you are thinking.. It seems to return a list of standard weather codes (Partly Sunny, Clear, etcetera) and the images used for each.

<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn" />

<cfset weatherArray = bweatherReturn.getWeatherDescription()>

<cfloop array="#weatherArray#" index="weather">

    <cfoutput>

    #weather.weatherid#<Br />

    #weather.Description#<br />

    #weather.PictureURL#<Br />

    </cfoutput>

</cfloop>

Message was edited by: -==cfSearching==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 27, 2010 Jul 27, 2010

Thank you!  It was wishful thinking on my part that it would combine the zip code with the description.  I put a simple <cfif> in the weather description loop that you created to get the results I wanted.  I was so locked into making it do what I wanted that I couldn't even get the array right! Thank you so much.  The array is just what I needed to make this work.  Thank you for your time.


<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getcityweatherbyzip" returnvariable="aWeatherReturn">
<cfinvokeargument name="ZIP" value="27502"/>
</cfinvoke>

<cfinvoke webservice="http://ws.cdyne.com/WeatherWS/Weather.asmx?wsdl" method="getweatherinformation" returnvariable="bWeatherReturn">
</cfinvoke>

<cfset weatherArray = bweatherReturn.getWeatherDescription()>

<cfloop array="#weatherArray#" index="weather">

<cfif weather.weatherid eq aweatherreturn.weatherid>

    <cfoutput>

    <img src="#weather.PictureURL#" /><Br />#aWeatherReturn.temperature#

    </cfoutput>
</cfif>

</cfloop>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 27, 2010 Jul 27, 2010

You are welcome.

By the way, if you only need one specific image there should be a getWeatherDescription(weatherID) method too.  You could use that method instead of having to loop through all of the descriptions every time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 27, 2010 Jul 27, 2010

What you're suggesting here is what I was initially trying to accomplish.  I have no idea how to call the record for a particular weatherid.  I output the record number and weatherid which don't match up.

aweatherreturn.weatherid = 14

bweatherreturn.weatherid = 14

bweatherreturn record # = 17

When I do it like this, <cfoutput>#weatherarray[aweatherreturn.weatherid].weatherid#</cfoutput>, so it is like:

weatherarray[14].weatherid = 17 rather than 14.  Does that make sense?

http://shepherdsvineyardpool.com/sites/dsp/dsp_weather.cfm?zipcode=27502

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2010 Jul 27, 2010

weatherarray[14].weatherid = 17 rather than 14

I don't fully understand what you are asking. You are looking at the index of 14 of the array which is WeatherID 17 in the list of Weather IDs and descriptions. If you are trying to find a specific weather ID, you should loop through the array to where the weatherarray.weatherid = the ID you are looking for.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 27, 2010 Jul 27, 2010

Yes, I did loop through the array to find the answer.  I was referring to another reply that suggested:

"if you only need one specific image there should be a getWeatherDescription(weatherID) method too."

I wasn't sure how to do that method so that I don't have to loop through the entire array.  The loop does work, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 28, 2010 Jul 28, 2010

On closer examination, that will not work.  Initially I thought the getWeatherDescription(int) argument was a "weatherID" value.  But it is actually an array index, which will not help here. So you could either loop, or use the other suggestion  ie grab the descriptions once and save them rather than retrieving them each time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 28, 2010 Jul 28, 2010

Ok.  That clarifies a lot for me.  I initially thought there was a way to do just as you suggested.  I couldn't get it to work right

for reasons I now understand.

The looping works fine and doesn't take any time at all.  I didn't want to download them to my server in case they change the values on their end.

Thank you for helping me through this learning experience.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 28, 2010 Jul 28, 2010
LATEST
I didn't want to download them to my server in case they change the values on their end.

True. But you could still design something that updates itself as needed. For example could create an empty structure to store the codes. You could either populate it when the application starts or when the first code is needed (lazy loading).  Anyway, each time a code is needed, check the structure to see if the weatherID exists. If it does not, go out to the site and get the current codes and add any missing values to your structure.  That would avoid running a request everytime and would still keep things up to date.  Granted running a new request and looping is the probably the easiest and most straight forward method 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2010 Jul 27, 2010

The third method does link to the other two with the Weather ID. The third method just simply returns a list of all available weather IDs, their description, and the Picture URL. Once you receive the weather ID from one of the other two methods you can match them up to know the description and have the picture URL.

You could always save the values to your server if you didnt want to loop through them everytime.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources