We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Alright everyone. This is my first shot at a snippet so I am sure there are plenty things that could be done better and some bugs here and there. Please let me know if you find any or have suggestions to make this better. I would be interested in seeing it used in the wild. By no means is it required, but if you do use it, post a link or send me a PM. I plan to upload this in the repository on Wednesday, pending no one finds anymore bugs. A demo can be found here:

    http://www.fredsbarn.com/sandbox/modx/index.php?id=60

    UPDATE:
    First of all, this new version supports Wunderground by default! (Thanks for the suggestion Alpaca) Also, you can now use parameters in the snippet call so you can multiple instances for multiple locales, in an easy way. Last, this is more redundant than the previous version. It defaults to using CURL, and if your PHP install doesn’t have CURL, then it tries to do an FOPEN on the URL. However, if you don’t have the http wrappers setup for FOPEN and you don’t have CURL support in your PHP install, then this script won’t work. Check the readme for more details!
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 11235
      • 16 Posts
      wow, great snipp! havent tried it yet.. but i like the idea
        • 16732
        • 592 Posts
        Hi jesster444,

        Your snippet seems great, but I’m wandering how I can use it for french citys ?

        I know that’s possible, I make the test on the weather.com site and if I put Paris or Bordeaux, I have results.

        I found that, when I edit the weather.com code page :
        <a href="/outlook/travel/businesstraveler/local/FRXX0016?from=search_current" onclick="setRecentSearch('FRXX0016','1','Bordeaux, FR','');">Current</a>
        

        http://xoap.weather.com/weather/local/FRXX0016?cc=*&&prod=xoap&par=xxxxxx&key=xxxxxx
        


        Now, if I put FRXX0016 in your query string connection
        http://xoap.weather.com/weather/local/FRXX0016?cc=*&&prod=xoap&par=xxxxxx&key=xxxxxx
        


        I get an xml output who seems good (got directly in brother window).

        <?xml version="1.0" encoding="ISO-8859-1"?>
        <!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
        <weather ver="2.0">
          <head>
            <locale>en_US</locale>
            <form>MEDIUM</form>
            <ut>F</ut>
            <ud>mi</ud>
            <us>mph</us>
            <up>in</up>
            <ur>in</ur>
          </head>
          <loc id="FRXX0016">
            <dnam>Bordeaux, France</dnam>
            <tm>2:37 PM</tm>
            <lat>44.83</lat>
            <lon>-0.7</lon>
            <sunr>7:42 AM</sunr>
            <suns>5:50 PM</suns>
            <zone>1</zone>
          </loc>
          <cc>
            <lsup>11/2/06 2:00 PM Local Time</lsup>
            <obst>Bordeaux, France</obst>
            <tmp>55</tmp>
            <flik>55</flik>
            <t>Fair</t>
            <icon>34</icon>
            <bar>
              <r>30.30</r>
              <d>steady</d>
            </bar>
            <wind>
              <s>16</s>
              <gust>N/A</gust>
              <d>50</d>
              <t>NE</t>
            </wind>
            <hmid>41</hmid>
            <vis>6.2</vis>
            <uv>
              <i>2</i>
              <t>Low</t>
            </uv>
            <dewp>32</dewp>
            <moon>
              <icon>11</icon>
              <t>Waxing Gibbous</t>
            </moon>
          </cc>
        </weather>
        
        


        But in fact my testing stop here because neither my local machine or my 1&1 hosting allows the use of http with the fopen function undecided

        If I can solve this problem, do you think there is a way to use something more explicit like "bordeaux, FR" for selecting the town ?

        Thanks

          • 14050
          • 788 Posts
          laurentc ,

          Have you been able to implement it successfully using an U.S. Zip Code, such as 62902? If that works fine, when you place in your post-code for your French cities, are you getting any errors, or any output?
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 7923
            • 4,213 Posts
            It doesnt matter if its French, US, or Mars weather if the server doesn’t allow fopen to http urls.. If your server supports CURL, you could try to use it to read the data.


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 1226
              • 5 Posts
              This is exactly the type of add-on I have been looking for. It might be a good idea use a publicly accessible RSS/XML feed from a site such as Accuweather or Wunderground. You could even make it so that the user can choose which Weather site to pull data from. Sure it is easy to register at weather.com for a key, but why not give the option to use other services? It would increase use of WeatherX.

              Awesome work so far.
                • 14050
                • 788 Posts
                That is a great idea Alpaca. Right now I used WeatherX as an opportunity to convert a preexisting PHP script into something that would work for ModX. The script I used, consequently, also used Weather.com. As I start to get my feet wet and learn more about coding in PHP and for ModX, I will try to add this as a feature. Also, feel free for anyone that knows how to code to go ahead and do this.
                  Jesse R.
                  Consider trying something new and extraordinary.
                  Illinois Wine

                  Have you considered donating to MODx lately?
                  Donate now. Every contribution helps.
                  • 16732
                  • 592 Posts
                  @doze: thanks for the CURL option ... I will try to use it
                    • 14050
                    • 788 Posts
                    Hey Lauren,

                    After finishing up my GoogleEvents parser, I took a look at Wunderground. It should be pretty straight forward to go through and serve up its feed similar to what I did with Weather.com. I will probably just allow the user to call the snippet with a parameter that specifies which service they want to get their information from. The nice thing about the public feeds is that we shouldn’t have to worry about writing to a file and waiting 10 or so minutes to update it. Thanks for the suggestion, and keep your eyes peeled for an updated version that supports that.
                      Jesse R.
                      Consider trying something new and extraordinary.
                      Illinois Wine

                      Have you considered donating to MODx lately?
                      Donate now. Every contribution helps.
                      • 1226
                      • 5 Posts
                      Keep up the good work jester. Good stuff out of this so far.