yahooのwebapi(厳密にはYOLPです)のphpファイルをpage-スラッグ名.phpとして保存し、固定ページとして投稿する事が出来ましたが、いざYOLPのphpファイルの固定ページを開くと、YOLPの情報が文字列で表示されます。(localhostのmampのindex ofにphpファイルを入れて表示する時と同じです)
どうすれば、YOLPの情報を文字列としてではなく、一つ一つの店舗として表示する事が出来ますか?
分かりにくい説明ですみません。例として挙げるなら、ホットペッパーや食べログみたいな店舗表示を目指しています。
因みに私が書いたphpコードは下記に掲載しました。 phpとwebapiの知識が全くないため、間違っているところがあると思います。 ご教授、お願いします
<?php /* Template Name: takeout */ ?> <?php if(have_posts()): while(have_posts()): the_post();?> <h2><?php the_title(); ?></h2> <?php the_content(); ?> <?php endwhile; endif; ?> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>YOLP</title> <head> <body> <?php $id = '私のid'; $area= 13; $ct ='0114'; $start = '1'; $url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=100&start='.$start.'&detail=full'; $xml = simplexml_load_file( $url ); $total = $xml ->ResultInfo->Total; $loop = (int)($total/100); $i = 0; while($i <= $loop){ $start = 100*$i+1; $url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=200&start='.$start.'&detail=full'; $xml = simplexml_load_file( $url ); foreach($xml->Feature as $item){ echo $item->Name. ',' . $item->Property->Yomi .',' . $item->Property->Tel1 . ',' . $item->Property->Address . ',' . $item->Property->Station->Railway . $item->Property->Station->Name . '駅' .$item->Property->Detail->OfficialPcUrl1; echo '<br />'; } $i++; } ?>