您错误地传递了请求参数。
看看Codex page. 你可以在那里找到这样的例子:
$response = wp_remote_post( $url, array(
\'method\' => \'POST\',
\'timeout\' => 45,
\'redirection\' => 5,
\'httpversion\' => \'1.0\',
\'blocking\' => true,
\'headers\' => array(),
\'body\' => array( \'username\' => \'bob\', \'password\' => \'1234xyz\' ),
\'cookies\' => array()
)
);
因此,在您的情况下,应该如下所示:
$args = array(
\'method\' => \'POST\',
\'headers\' => array(
\'Content-type: application/x-www-form-urlencoded\'
),
\'sslverify\' => false,
\'body\' => array(
\'api\' => get_option(\'API_key\'),
\'gw\' => \'1\'
)
);
$api_response = wp_remote_post(\'https://myurl.com/api\', $args);