回答編集履歴
3
修正
test
CHANGED
@@ -22,12 +22,6 @@
|
|
22
22
|
|
23
23
|
'method'=>"GET",
|
24
24
|
|
25
|
-
'header'=>"Accept-language: en\r\n" .
|
26
|
-
|
27
|
-
"Cookie: foo=bar\r\n",
|
28
|
-
|
29
|
-
|
30
|
-
|
31
25
|
'content'=> http_build_query(array(
|
32
26
|
|
33
27
|
'test1'=> 'test1',
|
2
追記
test
CHANGED
@@ -3,3 +3,49 @@
|
|
3
3
|
第3引数に[stream_context_create](http://php.net/manual/ja/function.stream-context-create.php)で作ったcontextを入れることで
|
4
4
|
|
5
5
|
GET,POST,DELETEとかをのっけてリクエストできます
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
以下ほぼまんまサンプルコード
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```PHP
|
14
|
+
|
15
|
+
<?php
|
16
|
+
|
17
|
+
// ストリームを作成します
|
18
|
+
|
19
|
+
$opts = array(
|
20
|
+
|
21
|
+
'http'=>array(
|
22
|
+
|
23
|
+
'method'=>"GET",
|
24
|
+
|
25
|
+
'header'=>"Accept-language: en\r\n" .
|
26
|
+
|
27
|
+
"Cookie: foo=bar\r\n",
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
'content'=> http_build_query(array(
|
32
|
+
|
33
|
+
'test1'=> 'test1',
|
34
|
+
|
35
|
+
'test2'=> 'テスト2',
|
36
|
+
|
37
|
+
))
|
38
|
+
|
39
|
+
),
|
40
|
+
|
41
|
+
);
|
42
|
+
|
43
|
+
$context = stream_context_create($opts);
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
// 上で設定した HTTP ヘッダを使用してファイルをオープンします
|
48
|
+
|
49
|
+
$file = file_get_contents('http://localhost/get.php', false, $context);
|
50
|
+
|
51
|
+
```
|
1
修正
test
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
できます
|
2
|
-
|
3
|
-
|
4
|
-
|
5
1
|
[file_get_contens](http://php.net/manual/ja/function.file-get-contents.php)の説明にも書いてますが
|
6
2
|
|
7
3
|
第3引数に[stream_context_create](http://php.net/manual/ja/function.stream-context-create.php)で作ったcontextを入れることで
|