php - Undefined Index Weather -
so made script, command.
what is, user defines command "weather" $arg $arg whatever that's being said. , decodes json get's produced , sends packet 2 things json. says "location" , "temperature" undefined.
could me fix this? packet get's sent doesn't show location or temperature when packet sent. packet sm = send message.
here code
if($cmd == 'weather'){ $file = file_get_contents('http://weather3.pricop.info/api.php?city=' . $arg); $weather = json_decode($file, true); $user->sendpacket("%xt%sm%-1%0%" . " temperature " . $weather["location"] . "%" . " " . $weather["temperature"] . "%"); }
the response looks like:
{"apiversion":"1.0", "data":{ "location":"pascagoula, ms", "temperature":"79", "skytext":"mostly cloudy", "humidity":"84", "wind":"6", "date":"2013-07-31", "day":"wednesday" } }
the returned data has location attribute inside of data attribute must reference.
$weather["data"]["location"];
and
$weather["data"]["temperature"];
Comments
Post a Comment