質問編集履歴
5
表記変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
file_get_contentsでの出力エラー
|
test
CHANGED
File without changes
|
4
表記変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
CURLでの出力エラー
|
test
CHANGED
File without changes
|
3
内容変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
-
◎send.php(nitta/send.php
|
43
|
+
◎send.php(nitp)ta/send.php
|
44
44
|
|
45
45
|
```
|
46
46
|
|
@@ -111,3 +111,65 @@
|
|
111
111
|
print_r($_POST);
|
112
112
|
|
113
113
|
```
|
114
|
+
|
115
|
+
訂正版
|
116
|
+
|
117
|
+
◎send.php(nitta/send.php)
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
<?php
|
122
|
+
|
123
|
+
$url = 'http://localhost:8000/api/reception.php/';
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
// POSTデータ
|
128
|
+
|
129
|
+
$data = array(
|
130
|
+
|
131
|
+
"key1" => "value1",
|
132
|
+
|
133
|
+
"key2" => "value2"
|
134
|
+
|
135
|
+
);
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
$data = http_build_query($data, "", "&");
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
$ch = curl_init(); // はじめ
|
144
|
+
|
145
|
+
curl_setopt($ch, CURLOPT_URL, $url);
|
146
|
+
|
147
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
148
|
+
|
149
|
+
curl_setopt($ch,CURLOPT_POST, true);
|
150
|
+
|
151
|
+
//データの配列を設定する
|
152
|
+
|
153
|
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
154
|
+
|
155
|
+
$html = curl_exec($ch);//実行
|
156
|
+
|
157
|
+
curl_close($ch);
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
var_dump($html);
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
?>
|
166
|
+
|
167
|
+
```
|
168
|
+
|
169
|
+
⇒出力結果
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
bool(false)
|
174
|
+
|
175
|
+
```
|
2
内容修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,6 +17,12 @@
|
|
17
17
|
|
18
18
|
|
19
19
|
URLが間違っているとは思えないのですが?
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
◎期待する答え
|
24
|
+
|
25
|
+
Array([key1] => value1 [key2] => value2)
|
20
26
|
|
21
27
|
|
22
28
|
|
1
内容修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,7 +86,7 @@
|
|
86
86
|
|
87
87
|
// POST送信
|
88
88
|
|
89
|
-
$contents = file_get_contents('http://localhost:8000/
|
89
|
+
$contents = file_get_contents('http://localhost:8000/reception.php', false, $context);
|
90
90
|
|
91
91
|
|
92
92
|
|