在 HTTP API Wordpress 中放置 HTTP 请求

Vis*_*nde 0 api wordpress http

我无法在 WordPress 中使用 put http 请求。

https://codex.wordpress.org/HTTP_API

这个链接说你可以做到wp_remote_request()吗?但是在哪里指定呢?

谁能帮我这个?我需要一个代码。

小智 5

$body = array(
            "status" => "publish"
);
$args = array(
    'headers' => array(
    'Content-Type'   => 'application/json',
    ),
    'body'      => json_encode($body),
    'method'    => 'PUT'
);

$result =  wp_remote_request( "http:300/wp-json/wp/post/1", $args );
Run Code Online (Sandbox Code Playgroud)