function kirimKeWordPress($url, $user, $pass, $title, $content, $status) { $api_url = rtrim($url, '/') . '/wp-json/wp/v2/posts'; $data = json_encode([ 'title' => $title, 'content' => $content, 'status' => $status ]); $ch = curl_init($api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_TIMEOUT, 15); // --- BYPASS SSL AGAR TIDAK ERROR CODE 0 --- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // ------------------------------------------ curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Authorization: Basic ' . base64_encode($user . ':' . $pass) ]); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return ['code' => $http_code, 'res' => json_decode($response, true)]; }