人人商城

gold.php 1.7KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. $message = $this->message;
  3. preg_match('/(.*)天气/', $message['content'], $match);
  4. $city = $match[1];
  5. $url = 'http://php.weather.sina.com.cn/xml.php?city=%s&password=DJOYnieT8234jlsK&day=0';
  6. $url = sprintf($url, urlencode(iconv('utf-8', 'gb2312', $city)));
  7. $resp = ihttp_get($url);
  8. $response = array();
  9. if ($resp['code'] = 200 && $resp['content']) {
  10. $obj = simplexml_load_string($resp['content'], 'SimpleXMLElement', LIBXML_NOCDATA);
  11. $dat = $obj->Weather->city . '今日天气' . PHP_EOL .
  12. '今天白天'.$obj->Weather->status1.','. $obj->Weather->temperature1 . '摄氏度。' . PHP_EOL .
  13. $obj->Weather->direction1 . ',' . $obj->Weather->power1 . PHP_EOL .
  14. '今天夜间'.$obj->Weather->status2.','. $obj->Weather->temperature2 . '摄氏度。' . PHP_EOL .
  15. $obj->Weather->direction2 . ',' . $obj->Weather->power2 . PHP_EOL .
  16. '==================' . PHP_EOL .
  17. '【穿衣指数】:' . $obj->Weather->chy_shuoming . PHP_EOL .PHP_EOL .
  18. '【感冒指数】:' . $obj->Weather->gm_l . $obj->Weather->gm_s . PHP_EOL .PHP_EOL .
  19. '【空调指数】:' . $obj->Weather->ktk_s . PHP_EOL .PHP_EOL .
  20. '【污染物扩散条件】:' . $obj->Weather->pollution_l . $obj->Weather->pollution_s . PHP_EOL .PHP_EOL .
  21. '【洗车指数】:' . $obj->Weather->xcz_l . $obj->Weather->xcz_s . PHP_EOL .PHP_EOL .
  22. '【运动指数】:' . $obj->Weather->yd_l . $obj->Weather->yd_s . PHP_EOL .PHP_EOL .
  23. '【紫外线指数】:' . $obj->Weather->zwx_l . $obj->Weather->zwx_s . PHP_EOL .PHP_EOL .
  24. '【体感度指数】:' . $obj->Weather->ssd_l . $obj->Weather->ssd_s . PHP_EOL ;
  25. $response = $this->respText($dat);
  26. }
  27. return $response;