回答編集履歴
5
微修正
answer
CHANGED
@@ -83,7 +83,7 @@
|
|
83
83
|
1. composer installでインストール
|
84
84
|
2. php client.phpで実行
|
85
85
|
|
86
|
-
### 参考までにLaravelでの受け口
|
86
|
+
### 参考までにLaravelでのルータの受け口
|
87
87
|
```
|
88
88
|
Route::post('server', function (\Illuminate\Http\Request $request) {
|
89
89
|
return $request->input("field1")."a";
|
4
Guzzle利用を追記
answer
CHANGED
@@ -53,4 +53,40 @@
|
|
53
53
|
```
|
54
54
|
|
55
55
|
ブラウザでhttp://localhost:9998/client.phpにアクセスし、client.phpからserver.phpへのcurlでの通信を実行
|
56
|
-
dump.txtにvar_dump結果の保存を確認
|
56
|
+
dump.txtにvar_dump結果の保存を確認
|
57
|
+
|
58
|
+
###追記 Guzzleを使ったclient.php
|
59
|
+
composer.json
|
60
|
+
```
|
61
|
+
{
|
62
|
+
"require": {
|
63
|
+
"guzzlehttp/guzzle": "^6.3"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
```
|
67
|
+
client.php
|
68
|
+
```
|
69
|
+
<?php
|
70
|
+
|
71
|
+
require 'vendor/autoload.php';
|
72
|
+
$client = new \GuzzleHttp\Client();
|
73
|
+
$res = $client->request('POST', 'http://localhost:9999/server',[
|
74
|
+
'form_params' => [
|
75
|
+
"field1"=>"test"
|
76
|
+
],
|
77
|
+
]);
|
78
|
+
|
79
|
+
echo $res->getBody();
|
80
|
+
echo $res->getStatusCode();
|
81
|
+
```
|
82
|
+
|
83
|
+
1. composer installでインストール
|
84
|
+
2. php client.phpで実行
|
85
|
+
|
86
|
+
### 参考までにLaravelでの受け口
|
87
|
+
```
|
88
|
+
Route::post('server', function (\Illuminate\Http\Request $request) {
|
89
|
+
return $request->input("field1")."a";
|
90
|
+
});
|
91
|
+
|
92
|
+
```
|
3
追記を微修正2
answer
CHANGED
@@ -49,7 +49,7 @@
|
|
49
49
|
//追記:ローカルサーバーのコンソールに出力
|
50
50
|
$stdout= fopen( 'php://stdout', 'w' );
|
51
51
|
fputs( $stdout, json_encode($_POST));
|
52
|
-
fclose( $
|
52
|
+
fclose( $stdout );
|
53
53
|
```
|
54
54
|
|
55
55
|
ブラウザでhttp://localhost:9998/client.phpにアクセスし、client.phpからserver.phpへのcurlでの通信を実行
|
2
追記を微修正
answer
CHANGED
@@ -48,8 +48,8 @@
|
|
48
48
|
|
49
49
|
//追記:ローカルサーバーのコンソールに出力
|
50
50
|
$stdout= fopen( 'php://stdout', 'w' );
|
51
|
-
|
51
|
+
fputs( $stdout, json_encode($_POST));
|
52
|
-
|
52
|
+
fclose( $fp );
|
53
53
|
```
|
54
54
|
|
55
55
|
ブラウザでhttp://localhost:9998/client.phpにアクセスし、client.phpからserver.phpへのcurlでの通信を実行
|
1
追記
answer
CHANGED
@@ -46,6 +46,10 @@
|
|
46
46
|
fputs($fp, $result);
|
47
47
|
fclose( $fp );
|
48
48
|
|
49
|
+
//追記:ローカルサーバーのコンソールに出力
|
50
|
+
$stdout= fopen( 'php://stdout', 'w' );
|
51
|
+
fwrite( $stdout, json_encode($_POST));
|
52
|
+
|
49
53
|
```
|
50
54
|
|
51
55
|
ブラウザでhttp://localhost:9998/client.phpにアクセスし、client.phpからserver.phpへのcurlでの通信を実行
|