如果不需要回复,如何使用 Wordpress wp_remote_post?

How to use Wordpress wp_remote_post if I don't need to get a response?

使用 wp_remote_post 将表单数据 (Contact Form 7) 发送到外部 API (CRM)。 API 很繁重(检查电子邮件、确认信等),所以我不希望 PHP 在等待响应时阻止任何进程(我根本不需要响应,只需发送).

尽管如此,即使 'blocking' => false 它确实如此 — 如果我在外部 API 上激活确认电子邮件,Wordpress 用户需要等待几秒钟才能处理表单。

我做错了什么? :) 代码:

// POST-request to API
wp_remote_post('http://crm.site.com/get_record', array(
    'timeout' => 5,
    'redirection' => 5,
    'httpversion' => '1.0',
    'blocking' => false,
    'headers' => array() ,
    'body' => $send_data,
    'cookies' => array()
));

我认为这里缺少方法,添加方法并尝试

   $response = wp_remote_post('http://crm.site.com/get_record', array(
    'method' => 'POST',
    'timeout' => 5,
    'redirection' => 5,
    'httpversion' => '1.0',
    'blocking' => false,
    'headers' => array() ,
    'body' => $send_data,
    'cookies' => array()
   ));

并检查响应:

if ( is_wp_error( $response ) ) {
   $error_message = $response->get_error_message();
   echo "Something went wrong: $error_message";
} else {
   echo 'Response:<pre>';
   print_r( $response );
   echo '</pre>';
}