테스트 사이트 - 개발 중인 베타 버전입니다

날씨관련 질문요 채택완료

zkdlf 9년 전 조회 2,062

바꿔봤는데 안먹어서 적어봤어요 http://api.wunderground.comᄋ/" target="_blank">http://api.wunderground.com 에서 가지고왔는데 내일 날씨

도 볼 수있도록 할려면 어떻게 해야하나요?

 

혹시 이게

//*density2002@naver.com *   

 

우선 밑에 거는 올래 CN이라고 되어있는곳에 EN으로 해서 영문으로 나오도록 했었는데 중문으로나오게할려고  CN으로 적었는데 중국어로 안나와요... 또 한 영문 중문 다 나오게할려고 하나를 추가해서 EN으로 했는데 밑에거는 안나와요...

  $url = "http://api.wunderground.com/api/3da28c0dbaf4e7/geolookup/conditions/lang:CN/q/Korea/Seoul.json" target="_blank">http://api.wunderground.com/api/3da28c0dbaf4e7/geolookup/conditions/lang:CN/q/Korea/Seoul.json";   $url = "http://api.wunderground.com/api/3da28c0db2f4e7/geolookup/conditions/lang:EN/q/Korea/Seoul.json" target="_blank">http://api.wunderground.com/api/3da28c0dbaf4e7/geolookup/conditions/lang:EN/q/Korea/Seoul.json";   $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");     curl_setopt($ch, CURLOPT_TIMEOUT, 60);     $return = curl_exec($ch);     curl_close($ch);         $json_string = $return;   $parsed_json = json_decode($json_string);   $location = $parsed_json->{'location'}->{'city'};   $temp_f = $parsed_json->{'current_observation'}->{'temp_f'};   $temp_c = $parsed_json->{'current_observation'}->{'temp_c'};   $uv = $parsed_json->{'current_observation'}->{'UV'};   $wind_kph = $parsed_json->{'current_observation'}->{'wind_kph'};   $weather = $parsed_json->{'current_observation'}->{'weather'};   $icon_url = $parsed_json->{'current_observation'}->{'icon_url'};     $api = "현재 날씨를 알려 드리겠습니다 $location 에는 섭씨$temp_f 도씨이며 온도 $temp_c 도씨입니다.현재날씨는 $weather 입니다. 풍속은 $wind_kph 입니다. 좋은 하루되십시요\n";   $apidata = "$location  $temp_c ℃   $weather  \n";  class TextToSpeech {  public $mp3data;  function __construct($text="") {         $text = trim($text);         if(!empty($text)) {             $text = urlencode($text);             $url = "http://translate.google.com/translate_tts?ie=utf-8&tl=ko&q=".$text;     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");     curl_setopt($ch, CURLOPT_TIMEOUT, 60);     $return = curl_exec($ch);     curl_close($ch);

 $this->mp3data = $return;         }     }       function setText($text) {         $text = trim($text);         if(!empty($text)) {             $text = urlencode($text);             $url = "http://translate.google.com/translate_tts?ie=utf-8&tl=ko&q=".$text;     $ch = curl_init();     curl_setopt($ch, CURLOPT_URL, $url);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");     curl_setopt($ch, CURLOPT_TIMEOUT, 60);     $return = curl_exec($ch);     curl_close($ch);

 $this->mp3data = $return;             return $mp3data;         } else { return false; }     }       function saveToFile($filename) {         $filename = trim($filename);         if(!empty($filename)) {             return file_put_contents($filename,$this->mp3data);         } else { return false; }     }   }

$data=$api;

$tts = new TextToSpeech(); $tts->setText($data);

?>

 

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

흠 차라리 기상청 API 가 쉬울꺼같은,.. 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인