날씨 정보 오류??

날씨 정보 오류??

QA

날씨 정보 오류??

본문

올래는 구름 해 등 이런 이미지가 뜨고 서울이면 서울 몇도 이런게 떻는데 갑자기 안나오네요?

온도: 섭씨: 날씨:  이렇게만 뜨네요.... 한번만 봐주세요

 

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<?php 
 //*Copyright © HoneyMusic*
 //*Yu-sung heon          *
 //**** 개인정보보호를 위한 이메일주소 노출방지 *** *
 
  $url = "http://api.wunderground.com/api/e9e0b719ce8b9e95/geolookup/conditions/lang:KR/q/Korea/Cheongju.json.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 섭씨: $temp_f 날씨: $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);
$tts->saveToFile("masnun.mp3");

?>

<audio controls="controls" autoplay="autoplay">
  <source src="masnun.mp3" type="audio/mpeg"/>
</audio><br>
<img src="<?=$icon_url;?>" height="30" ><? echo $apidata; ?>  

이 질문에 댓글 쓰기 :

답변 3



API키 문제인거 같아요. 다른 사람의 API를 사용하신거 같아요.


여기 들어가셔서 키 만드는 방법 찾아보시는게 좋을거 같아요

json 데이터 가져오는 부분이 뭔가 맞지 않는듯 한데요 파일을 보는데 원하시는 데이터가 없어서 안보이는 겁니다. 경로를 확인해 보셔야 할듯 합니다.

키라는 값이 생긴거 같은데 키를 안넣어서 오류가 뜨는거 같습니다.

 

http://api.wunderground.com/api/e9e0b719ce8b9e95/geolookup/conditions/lang:KR/q/Korea/Cheongju.json.json 

 

접속 해보시면 

 


 
{
  "response": {
  "version":"0.1",
  "termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
  "features": {
  }
		,
	"error": {
		"type": "invalidkey"
		,"description": "this key is not valid due to exceeding rate plan"
	}
	}
}

에러 메시지를 뱉는데 혹시 키값을 가지고 있나요?
답변을 작성하시기 전에 로그인 해주세요.
전체 13
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT