post_id, $cloudRequest->post_title, $json); // wp remote call to POLYLAI_WS_URL $response = wp_remote_post(POLYLAI_WS_URL . "/translate", [ 'timeout' => 100000, 'method' => 'POST', 'blocking' => true, 'body' => json_encode($cloudRequest), 'headers' => [ "Content-Type" => "application/json", "Accept" => "application/json" ] ]); // throw new Exception(json_encode($cloudRequest)); if (is_wp_error($response)) { $response = new stdClass(); $response->success = false; $response->error = $response->get_error_message(); return $response; } // throw new Exception(json_encode($response)); return json_decode($response['body']); } /** * Summary of getStatus * @param polylai_CloudStatus $request */ public static function getStatus($request) { $response = wp_remote_get(POLYLAI_WS_URL . "/status", [ 'timeout' => 100000, 'method' => 'POST', 'blocking' => true, 'body' => json_encode($request), 'headers' => [ "Content-Type" => "application/json" ] ]); if (is_wp_error($response)) { //print_r($response); return 'error'; } $response = json_decode($response['body']); if ($response->success) { return $response->status; } return []; } }