livedoorで天気予報のAPIの移行です。
156_API-test_on_sakuravps
が過去参考。
156_API-test_on_sakuravps
が過去参考。
http://160.16.50.187/API-test/20170115_tenki_simple.php/
なので、
153.126.154.106
ik1-313-16602.vs.sakura.ne.jp
を使って、
http://153.126.154.106/API-test/20170115_tenki_simple.php/
http://ik1-313-16602.vs.sakura.ne.jp/API-test/20170115_tenki_simple.php/
すりゃいいかな???
なので、
153.126.154.106
ik1-313-16602.vs.sakura.ne.jp
を使って、
http://153.126.154.106/API-test/20170115_tenki_simple.php/
http://ik1-313-16602.vs.sakura.ne.jp/API-test/20170115_tenki_simple.php/
すりゃいいかな???
/var/www/html/
の配下に
API-test
フォルダを作成して、
20170115_tenki_simple.php
を作成します。
の配下に
API-test
フォルダを作成して、
20170115_tenki_simple.php
を作成します。
<?php
$tmp_url = “http://weather.livedoor.com/forecast/webservice/json/v1?city=130010”;
$json = file_get_contents($tmp_url,true) or die(“Failed to get json”);
$json = mb_convert_encoding($json, ‘UTF8’, ‘ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN’);
$obj = json_decode($json);
$img_url = $obj->forecasts[0]->image->url;
$date = $obj->forecasts[0]->date;
$title = $obj->forecasts[0]->image->title;
$img_url1 = $obj->forecasts[1]->image->url;
$date1 = $obj->forecasts[1]->date;
$title1 = $obj->forecasts[1]->image->title;
$tmp_url = “http://weather.livedoor.com/forecast/webservice/json/v1?city=130010”;
$json = file_get_contents($tmp_url,true) or die(“Failed to get json”);
$json = mb_convert_encoding($json, ‘UTF8’, ‘ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN’);
$obj = json_decode($json);
$img_url = $obj->forecasts[0]->image->url;
$date = $obj->forecasts[0]->date;
$title = $obj->forecasts[0]->image->title;
$img_url1 = $obj->forecasts[1]->image->url;
$date1 = $obj->forecasts[1]->date;
$title1 = $obj->forecasts[1]->image->title;
$img_url2 = $obj->forecasts[2]->image->url;
$date2 = $obj->forecasts[2]->date;
$title2 = $obj->forecasts[2]->image->title;
$date2 = $obj->forecasts[2]->date;
$title2 = $obj->forecasts[2]->image->title;
?>
<h2>東京都の天気_Part2</h2>
<h4>(2017/04/30_sakravps2向けにリニューアル)</h4>
<div>
<h4>(2017/04/30_sakravps2向けにリニューアル)</h4>
<div>
<p> >TODAY : <?php echo $date; ?></p>
<p> <?php echo “<img src='”.$img_url.”‘>”; ?> <?php echo $title; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
<p> <?php echo “<img src='”.$img_url.”‘>”; ?> <?php echo $title; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
<p> >TOMMOROW : <?php echo $date1;?></p>
<p> <?php echo “<img src='”.$img_url1.”‘>”; ?> <?php echo $title1; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
<p> <?php echo “<img src='”.$img_url1.”‘>”; ?> <?php echo $title1; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
<p> >The day after TOMMOROW : <?php echo $date2;?></p>
<p> <?php echo “<img src='”.$img_url2.”‘>”; ?> <?php echo $title2; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
<p> <?php echo “<img src='”.$img_url2.”‘>”; ?> <?php echo $title2; ?></p>
<p> copyright <a href=”http://weather.livedoor.com/”>livedoor 天気情報</a>'</p>
</div>
全角半角問題に注意!!
以上(これも良し、と)