質問編集履歴
7
php
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
$id = '
|
39
|
+
$id = '私のid';
|
40
40
|
|
41
41
|
$area = 13;
|
42
42
|
|
6
php
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,70 +4,74 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
|
7
|
+
```PHP
|
8
8
|
|
9
|
-
|
9
|
+
<?php
|
10
10
|
|
11
|
-
|
11
|
+
/*
|
12
12
|
|
13
|
-
|
13
|
+
Template Name: tokyorestaurantinfo
|
14
14
|
|
15
|
-
|
15
|
+
*/
|
16
16
|
|
17
|
-
>
|
17
|
+
?>
|
18
18
|
|
19
|
-
> <!DOCTYPE html>
|
20
19
|
|
21
|
-
> <html lang="ja">
|
22
20
|
|
23
|
-
|
21
|
+
<!DOCTYPE html>
|
24
22
|
|
25
|
-
|
23
|
+
<html lang="ja">
|
26
24
|
|
27
|
-
|
25
|
+
<head>
|
28
26
|
|
29
|
-
|
27
|
+
<meta charset="UTF-8">
|
30
28
|
|
31
|
-
>
|
29
|
+
<title>東京の店舗情報</title>
|
32
30
|
|
33
|
-
|
31
|
+
<head>
|
34
32
|
|
35
|
-
>
|
33
|
+
<body>
|
36
34
|
|
37
|
-
|
35
|
+
<?php
|
38
36
|
|
39
|
-
|
37
|
+
|
40
38
|
|
41
|
-
|
39
|
+
$id = 'dj0zaiZpPWZKMnpnYUN0WEdVcSZzPWNvbnN1bWVyc2VjcmV0Jng9NGM-';
|
42
40
|
|
43
|
-
|
41
|
+
$area = 13;
|
44
42
|
|
45
|
-
|
43
|
+
$ct = '01';
|
46
44
|
|
47
|
-
|
45
|
+
$start = '1';
|
48
46
|
|
49
|
-
|
47
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='. $id .'&ac='. $area .'&gc='. $ct .'&results=100&start='. $start .'&detail=full';
|
50
48
|
|
51
|
-
>
|
52
49
|
|
53
|
-
> echo '<table class="left">';
|
54
50
|
|
55
|
-
|
51
|
+
$xml = simplexml_load_file( $url );
|
56
52
|
|
57
|
-
> $html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></td>%8$s</td></tr>';
|
58
53
|
|
59
|
-
>
|
60
54
|
|
61
|
-
|
55
|
+
echo '<table class="left">';
|
62
56
|
|
63
|
-
>
|
57
|
+
echo '<style scoped>table{width:80%;margin:auto;}td{border-bottom:1px solid #ccc;}td{color:#2980b9;}</style>';
|
64
58
|
|
65
|
-
|
59
|
+
$html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></td>%8$s</td></tr>';
|
66
60
|
|
67
|
-
> }
|
68
61
|
|
69
|
-
> echo '</table>';
|
70
62
|
|
71
|
-
>
|
63
|
+
foreach ( $xml->Feature as $item ) {
|
72
64
|
|
73
|
-
|
65
|
+
|
66
|
+
|
67
|
+
printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1,$item->Property->Image1 );
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
echo '</table>';
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
?>
|
76
|
+
|
77
|
+
```
|
5
php
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,70 +4,70 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
><?php
|
7
|
+
> <?php
|
8
8
|
|
9
|
-
/*
|
9
|
+
> /*
|
10
10
|
|
11
|
-
Template Name: tokyorestaurantinfo
|
11
|
+
> Template Name: tokyorestaurantinfo
|
12
12
|
|
13
|
-
*/
|
13
|
+
> */
|
14
14
|
|
15
|
-
?>
|
15
|
+
> ?>
|
16
16
|
|
17
|
+
>
|
17
18
|
|
19
|
+
> <!DOCTYPE html>
|
18
20
|
|
19
|
-
<
|
21
|
+
> <html lang="ja">
|
20
22
|
|
21
|
-
<h
|
23
|
+
> <head>
|
22
24
|
|
23
|
-
<he
|
25
|
+
> <meta charset="UTF-8">
|
24
26
|
|
25
|
-
<
|
27
|
+
> <title>東京の店舗情報</title>
|
26
28
|
|
27
|
-
|
29
|
+
> <head>
|
28
30
|
|
29
|
-
<
|
31
|
+
> <body>
|
30
32
|
|
31
|
-
<
|
33
|
+
> <?php
|
32
34
|
|
33
|
-
|
35
|
+
>
|
34
36
|
|
35
|
-
|
37
|
+
> $id = 'dj0zaiZpPWZKMnpnYUN0WEdVcSZzPWNvbnN1bWVyc2VjcmV0Jng9NGM-';
|
36
38
|
|
37
|
-
$
|
39
|
+
> $area = 13;
|
38
40
|
|
39
|
-
$
|
41
|
+
> $ct = '01';
|
40
42
|
|
41
|
-
$
|
43
|
+
> $start = '1';
|
42
44
|
|
43
|
-
$star
|
45
|
+
> $url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='. $id .'&ac='. $area .'&gc='. $ct .'&results=100&start='. $start .'&detail=full';
|
44
46
|
|
45
|
-
|
47
|
+
>
|
46
48
|
|
49
|
+
> $xml = simplexml_load_file( $url );
|
47
50
|
|
51
|
+
>
|
48
52
|
|
49
|
-
|
53
|
+
> echo '<table class="left">';
|
50
54
|
|
55
|
+
> echo '<style scoped>table{width:80%;margin:auto;}td{border-bottom:1px solid #ccc;}td{color:#2980b9;}</style>';
|
51
56
|
|
57
|
+
> $html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></td>%8$s</td></tr>';
|
52
58
|
|
53
|
-
|
59
|
+
>
|
54
60
|
|
55
|
-
ech
|
61
|
+
> foreach ( $xml->Feature as $item ) {
|
56
62
|
|
57
|
-
|
63
|
+
>
|
58
64
|
|
65
|
+
> printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1,$item->Property->Image1 );
|
59
66
|
|
67
|
+
> }
|
60
68
|
|
61
|
-
|
69
|
+
> echo '</table>';
|
62
70
|
|
71
|
+
>
|
63
72
|
|
64
|
-
|
65
|
-
printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1,$item->Property->Image1 );
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
echo '</table>';
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
?>引用テキスト
|
73
|
+
> ?>
|
4
php
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,31 +8,11 @@
|
|
8
8
|
|
9
9
|
/*
|
10
10
|
|
11
|
-
Template Name: t
|
11
|
+
Template Name: tokyorestaurantinfo
|
12
12
|
|
13
13
|
*/
|
14
14
|
|
15
15
|
?>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<?php
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if(have_posts()): while(have_posts()): the_post();?>
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
<h2><?php the_title(); ?></h2>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
<?php the_content(); ?>
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
<?php endwhile; endif; ?>
|
36
16
|
|
37
17
|
|
38
18
|
|
@@ -44,7 +24,7 @@
|
|
44
24
|
|
45
25
|
<meta charset="UTF-8">
|
46
26
|
|
47
|
-
<title>
|
27
|
+
<title>東京の店舗情報</title>
|
48
28
|
|
49
29
|
<head>
|
50
30
|
|
@@ -52,66 +32,42 @@
|
|
52
32
|
|
53
33
|
<?php
|
54
34
|
|
55
|
-
|
35
|
+
|
56
36
|
|
57
|
-
|
37
|
+
$id = 'dj0zaiZpPWZKMnpnYUN0WEdVcSZzPWNvbnN1bWVyc2VjcmV0Jng9NGM-';
|
58
38
|
|
59
|
-
|
39
|
+
$area = 13;
|
60
40
|
|
61
|
-
|
41
|
+
$ct = '01';
|
62
42
|
|
63
|
-
|
43
|
+
$start = '1';
|
64
44
|
|
65
|
-
|
66
|
-
|
67
|
-
$ct ='0114';
|
68
|
-
|
69
|
-
$start = '1';
|
70
|
-
|
71
|
-
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=100&start='.$start.'&detail=full';
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
$xml = simplexml_load_file( $url );
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
$total = $xml ->ResultInfo->Total;
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
$loop = (int)($total/100);
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
$i = 0;
|
90
|
-
|
91
|
-
while($i <= $loop){
|
92
|
-
|
93
|
-
$start = 100*$i+1;
|
94
|
-
|
95
|
-
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=200&start='.$start.'&detail=full';
|
96
|
-
|
97
|
-
$xml = simplexml_load_file( $url );
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
foreach($xml->Feature as $item){
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
echo $item->Name. ',' . $item->Property->Yomi .',' . $item->Property->Tel1 . ',' . $item->Property->Address . ',' . $item->Property->Station->Railway . $item->Property->Station->Name . '駅' .$item->Property->Detail->OfficialPcUrl1;
|
106
|
-
|
107
|
-
echo '<br />';
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
$i++;
|
112
|
-
|
113
|
-
}
|
45
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='. $id .'&ac='. $area .'&gc='. $ct .'&results=100&start='. $start .'&detail=full';
|
114
46
|
|
115
47
|
|
116
48
|
|
117
|
-
|
49
|
+
$xml = simplexml_load_file( $url );
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
echo '<table class="left">';
|
54
|
+
|
55
|
+
echo '<style scoped>table{width:80%;margin:auto;}td{border-bottom:1px solid #ccc;}td{color:#2980b9;}</style>';
|
56
|
+
|
57
|
+
$html = '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td><td>%4$s</td><td>%5$s</td><td>%6$s</td><td>%7$s</td></td>%8$s</td></tr>';
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
foreach ( $xml->Feature as $item ) {
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
printf( $html, $item->Name, $item->Property->Yomi, $item->Property->Tel1, $item->Property->Address, $item->Property->Station->Railway, $item->Property->Station->Name . '駅', $item->Property->Detail->OfficialPcUrl1,$item->Property->Image1 );
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
echo '</table>';
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
?>引用テキスト
|
3
phpコードを入れました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
<?php
|
54
54
|
|
55
|
-
$id = '
|
55
|
+
$id = '私のid';
|
56
56
|
|
57
57
|
$area= 13;
|
58
58
|
|
2
僕が作成したphpコードを入れました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,117 @@
|
|
1
1
|
wordpressでyahooのapi(特にyolp)を使いたいのですが、apiをphpで使用するにあたってapiの詳しいコードが分かりません。一応、phpコードは適当に書いたのですが、csv仕様になってしまい自分が思ってたphpコードになっていませんでした。
|
2
2
|
|
3
3
|
もし宜しければ、詳しいコードを教えてください。
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
><?php
|
8
|
+
|
9
|
+
/*
|
10
|
+
|
11
|
+
Template Name: takeout
|
12
|
+
|
13
|
+
*/
|
14
|
+
|
15
|
+
?>
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
<?php
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
if(have_posts()): while(have_posts()): the_post();?>
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
<h2><?php the_title(); ?></h2>
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
<?php the_content(); ?>
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<?php endwhile; endif; ?>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
<!DOCTYPE html>
|
40
|
+
|
41
|
+
<html lang="ja">
|
42
|
+
|
43
|
+
<head>
|
44
|
+
|
45
|
+
<meta charset="UTF-8">
|
46
|
+
|
47
|
+
<title>YOLP</title>
|
48
|
+
|
49
|
+
<head>
|
50
|
+
|
51
|
+
<body>
|
52
|
+
|
53
|
+
<?php
|
54
|
+
|
55
|
+
$id = 'dj0zaiZpPWZKMnpnYUN0WEdVcSZzPWNvbnN1bWVyc2VjcmV0Jng9NGM-';
|
56
|
+
|
57
|
+
$area= 13;
|
58
|
+
|
59
|
+
$area =get_post_meta($post->ID, Area, true);
|
60
|
+
|
61
|
+
$city =urlencode($area);
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
$ct ='0114';
|
68
|
+
|
69
|
+
$start = '1';
|
70
|
+
|
71
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=100&start='.$start.'&detail=full';
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
$xml = simplexml_load_file( $url );
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
$total = $xml ->ResultInfo->Total;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
$loop = (int)($total/100);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
$i = 0;
|
90
|
+
|
91
|
+
while($i <= $loop){
|
92
|
+
|
93
|
+
$start = 100*$i+1;
|
94
|
+
|
95
|
+
$url = 'http://search.olp.yahooapis.jp/OpenLocalPlatform/V1/localSearch?appid='.$id.'&ac='.$area.'&gc='.$ct.'&results=200&start='.$start.'&detail=full';
|
96
|
+
|
97
|
+
$xml = simplexml_load_file( $url );
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
foreach($xml->Feature as $item){
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
echo $item->Name. ',' . $item->Property->Yomi .',' . $item->Property->Tel1 . ',' . $item->Property->Address . ',' . $item->Property->Station->Railway . $item->Property->Station->Name . '駅' .$item->Property->Detail->OfficialPcUrl1;
|
106
|
+
|
107
|
+
echo '<br />';
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
$i++;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
?>
|
1
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|