0
제 문제는 제가 지금까지 wordpress 플러그인 중 하나 인 에 POST
요청을했지만 지금은 wp_remote_post()
을 사용해야합니다.WordPress cURL 및 wp_remote_post
wp_remote_post
나는 간단하게 보이지만 제대로 작동하지 않습니다. 그럼 내 질문은 : 누군가가 내wp_remote_post
로 전송할 수있는 방법을 보여줄 수 있을까요?
컬 : 승인이 작동하지 않았기 때문에 wp_remote_post
$result = wp_remote_post($url, array(
'method' => 'POST',
'headers' => $headers,
'body' => json_encode($fields))
);
의
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
내 버전은 내가 wp_remote_post
로 401 오류가 발생합니다.