Global It Leader!!



 
 

PHP 말하는 실시간 날씨정보 세계날씨

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,800회 작성일 14-01-23 01:11

본문

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<?php 
 //*Copyright © HoneyMusic*
 //*Yu-sung heon          *
 //*density2002@naver.com *
 
  $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; ?>

첨부파일

  • ds.zip (1.2K) 16회 다운로드 | DATE : 2014-01-23 01:11:34

댓글목록

등록된 댓글이 없습니다.

전체 440
게시물 검색
컴퓨터언어 목록
번호 제목 글쓴이 조회 날짜
열람중 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4801 01-23
279 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4577 01-21
278 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4413 01-21
277 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5168 01-21
276 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4782 01-18
275 PHP no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5620 01-18
274 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4533 12-31
273 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4478 12-25
272 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 11589 12-25
271 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5440 12-24
270 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4872 12-24
269 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4664 12-23
268 CSS no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4385 12-23
267 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5105 12-20
266 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4935 12-20
265 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6300 12-20
264 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4896 12-20
263 VB no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10186 12-19
262 Javasript no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4240 12-19
261 Mysql no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4637 12-18