bradyemerson / weatherbug-api-php

Automatically exported from code.google.com/p/weatherbug-api-php
0 stars 0 forks source link

Inconsistent response when using wb_forecast #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is a carry over from the Google Groups.

When I use the Function "wb_forecast"  the wrapper  does not seem to
return the values for the following:
  $forecast['webURL'] ,  $forecast['type'] ,    $forecast['date'],
$forecast['location']['city'], $forecast['location']['state'],
$forecast['location']['zipcode'] and $forecast['location']['zone'].

They all come back blank although they are present in the feed.  Am I
missing something? 

---

I have since found the solution.  The feed sent by a zip request is different
to that sent by a citycode or a lat/long request so the pre_match statement in 
the function
"wb_forecast" had to be changed from:

ZIP
preg_match("/<aws:WebURL>(.*?)<\/aws:WebURL><aws:forecasts 
type=\"(.*?)\"date=\"(.*?)\"
><aws:location><aws:city>(.*?)<\/aws:city><aws:state>(.*?)<\/aws:state><aws:zip>
([0-9]

*?)<\/aws:zip><aws:zone>(.*?)<\/aws:zone><\/aws:location>/", $file, $results);

to:

CITYCODE
preg_match("/<aws:WebURL>(.*?)<\/aws:WebURL><aws:forecasts type=\"(.*?)\" 
date=\"(.*?)\"
><aws:location><aws:city>(.*?)<\/aws:city><aws:citycode>([0-9]*?)<\/aws:citycode
><aws:

country>(.*?)<\/aws:country><\/aws:location>/", $file, $results);

I’m no programmer so I was pleased to be able find a fix.

I guess the code should check for the type of request and then use the 
appropriate preg_match
statement so it covers all possibilities. 

Original issue reported on code.google.com by meman1...@gmail.com on 3 Apr 2011 at 8:52

GoogleCodeExporter commented 9 years ago
Found an analogue issue using wb_station_List with citiCode. How can i modify 
the preg_match to fix that?

Original comment by manuel.n...@gmail.com on 16 Oct 2011 at 8:42

GoogleCodeExporter commented 9 years ago
Hi Manuel, do you know is the field you are looking for "citiCode" or is that a 
typo for "cityCode"? Can you send me the value that is not being picked up 
properly by the preg_match?

Original comment by meman1...@gmail.com on 17 Nov 2011 at 12:12

GoogleCodeExporter commented 9 years ago

Original comment by bra...@gmail.com on 17 Nov 2011 at 3:12