Set the content-type with wp_remote_post

前端 未结 1 820
天命终不由人
天命终不由人 2021-01-22 13:40

How can I set the content-type field to application/json in the header of my HTTP request when using the function wp_remote_post ?

相关标签:
1条回答
  • 2021-01-22 13:46

    Check the documentation for wp_remote_post which will give you some extra information on what you can do with the remote request.

    When you make the request using that function, you can set headers in the second parameter ($args) within an array. For example:

    $args = array(
        'headers' => array(
            'content-type' => 'application/json'
        ),
    );
    
    $request = wp_remote_post( $url, $args );
    
    0 讨论(0)
提交回复
热议问题