@@ -112,7 +112,10 @@ public function get(array $data = []): array
112112 return [];
113113 }
114114
115- curl_setopt ($ handle , CURLOPT_HTTPHEADER , array (sprintf ("Authorization: Token %s " , $ this ->token )));
115+ curl_setopt ($ handle , CURLOPT_HTTPHEADER , array (
116+ sprintf ("Authorization: Token %s " , $ this ->token )
117+ ));
118+ curl_setopt ($ handle , CURLOPT_RETURNTRANSFER , true );
116119
117120 // make request and return empty array on error
118121 $ json = Curl::execute_with_retry ($ handle );
@@ -178,6 +181,9 @@ public function post(array $data): Post_Result
178181 curl_setopt ($ handle , CURLOPT_HTTPHEADER , array (
179182 sprintf ("Authorization: Token %s " , $ this ->token )
180183 ));
184+ curl_setopt ($ handle , CURLOPT_POST , true );
185+ curl_setopt ($ handle , CURLOPT_POSTFIELDS , $ form );
186+ curl_setopt ($ handle , CURLOPT_RETURNTRANSFER , true );
181187
182188 // make request and output on error
183189 $ json = Curl::execute_with_retry ($ handle );
@@ -188,8 +194,9 @@ public function post(array $data): Post_Result
188194
189195 // decode JSON response and output on error
190196 $ result = json_decode ($ json , true );
191- if ($ error = Arr::get_array ($ result , "error " )) {
192- return new Post_Result (400 , Arr::get ($ error , "detail " ));
197+ if ($ error = Arr::get ($ result , "error " )) {
198+ $ detail = is_array ($ error ) ? Arr::get ($ error , "detail " ) : $ error ;
199+ return new Post_Result (400 , $ detail );
193200 }
194201
195202 // if we get here the POST was successful
0 commit comments