質問編集履歴
3
zzz
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```コマンドライン
|
20
20
|
|
21
|
-
curl -u xxx:yyy -F "image=@.
|
21
|
+
curl -u xxx:yyy -F "image=@.zzz" http://whatcat.ap.mextractr.net/api_query
|
22
22
|
|
23
23
|
xxx : 「この猫なに猫?」のユーザ名
|
24
24
|
|
2
コード変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,6 +126,24 @@
|
|
126
126
|
|
127
127
|
|
128
128
|
|
129
|
+
$image_url='./public/download.jpeg';
|
130
|
+
|
131
|
+
$base = "http://whatcat.ap.mextractr.net/api_query";
|
132
|
+
|
133
|
+
// $param = "?username=env('whatcat_username')&passowrd=env('whatcat_password')&image=$image_url";
|
134
|
+
|
135
|
+
$param = "?username=env('whatcat_username')&passowrd=env('whatcat_password')&image='@'.$image_url";
|
136
|
+
|
137
|
+
$url = $base . $param;
|
138
|
+
|
139
|
+
$headers = [];
|
140
|
+
|
141
|
+
$method='GET';
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
129
147
|
$curl = curl_init();
|
130
148
|
|
131
149
|
curl_setopt($curl, CURLOPT_URL, $url);
|
1
追加テスト
test
CHANGED
File without changes
|
test
CHANGED
@@ -117,3 +117,59 @@
|
|
117
117
|
|
118
118
|
|
119
119
|
すごく初心者なのでそれをふまえて回答いただけると助かります。
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
上記のhttps://note.com/kawa1228/n/n55b3cfcb543cを参考にさらにやってみた
|
124
|
+
|
125
|
+
```php
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$curl = curl_init();
|
130
|
+
|
131
|
+
curl_setopt($curl, CURLOPT_URL, $url);
|
132
|
+
|
133
|
+
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
|
134
|
+
|
135
|
+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
136
|
+
|
137
|
+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
138
|
+
|
139
|
+
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
$responseJsonText = curl_exec($curl);
|
146
|
+
|
147
|
+
$body = json_decode($responseJsonText , true);
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
152
|
+
|
153
|
+
curl_close($curl); // curlの処理終わり
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
$result = [];
|
158
|
+
|
159
|
+
$result['http_code'] = $httpCode;
|
160
|
+
|
161
|
+
$result['body'] = $body;
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
return $result;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
dd($result);
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
結果表示
|
174
|
+
|
175
|
+
{"http_code":403,"body":{"detail":"\u8a8d\u8a3c\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u305b\u3093\u3002"}}
|