teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

実行結果を追加しました。

2020/03/29 14:22

投稿

ppap115
ppap115

スコア11

title CHANGED
File without changes
body CHANGED
@@ -33,9 +33,34 @@
33
33
  ```
34
34
 
35
35
  ### 試したこと
36
+ コンテンツタイプの指定、ヘッダー情報がないことでのエラーではないかと下記コードを実行しましたがエラーになりました。
36
37
 
38
+ ```php
37
- ここに問題に対して試したことを記載してください。
39
+ <?php
38
40
 
41
+ $url = "https://www.hellowork.mhlw.go.jp/kensaku/GECA110010.do";
42
+ $data = array(
39
- ### 補足情報(FW/ツールのバージョンなど)
43
+ "tDFK1CmbBox" => 13,
44
+ "fwListNaviBtn1" => 1
45
+ );
40
46
 
47
+ $header = array(
48
+ "Content-Type: application/x-www-form-urlencoded",
49
+ "Content-Length: ".strlen($data)
50
+ );
51
+
52
+ $options = array("http" => array(
53
+ "method" => "POST",
54
+ "content" => http_build_query($data),
55
+ ));
56
+ $text = file_get_contents($url, false, stream_context_create($options));
57
+ ```
58
+ エラーメッセージ
59
+ ```
60
+ Warning: strlen() expects parameter 1 to be string, array given in C:\xampp\htdocs\get_post\index.php on line 11
61
+
62
+ Notice: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded in C:\xampp\htdocs\get_post\index.php on line 18
63
+ ```
64
+
41
- ここにより詳細な情報を記載てください。
65
+ どうすれば情報を取得できるでょうか?
66
+ よろしくお願いします。