Use the Authorization
header. Example:
$auth = base64_encode( $username . ':' . $password );
$args = [
'headers' => [
'Authorization' => "Basic $auth"
],
'body' => $body,
];
$response = wp_remote_post( $url, $args );
$response_body = wp_remote_retrieve_body( $response );
Related Posts:
- How to remove rest api link: in http headers?
- HTTP request on localhost failing
- Setting Last Modified HTTP Header on static Home Page
- If Modified Since HTTP Header
- Remove rel=shortlink from HTTP header
- Change the headers content type with wp_remote_post
- HTTP Header on specific page is application instead of text
- Authenticate a user for current request
- WordPress 502 | Header Upstream send too big
- What is this HTTP_REFERRER “WordPress/4.1.2”
- Enable CORS for getting an inline SVG by URL
- Why is http header providing 404 while site is online?
- How do you modify HTTP response headers on feed/?
- How to define the basic HTTP authentication using cURL correctly?
- How to do a PUT request with cURL?
- PHP + curl, HTTP POST sample code?
- Can PHP cURL retrieve response headers AND body in a single request?
- How to use OAuth authentication with REST API via CURL commands?
- How does one suppress a 404 status code in a WordPress page?
- Admin bar and fixed header issue?
- disable wordpress canonical tag meta
- Disable h1 and h2 from rich text editor combobox
- Recommended location to set response headers?
- Is it safe to fix Access-Control-Allow-Origin (CORS origin) errors with a php header directive?
- Custom endpoint and X-WP-TotalPages (headers)
- Clarity needed on usage of multiple 403 forbidden header() functions at the beginning of the plugin files
- Log in from one wordpress website to another wordpress website
- Additional Option on Custom Header admin
- How can I change HTTP headers only to posts of a specific category from a plugin
- Getting redirect to happen before header output
- Retrieving Google Plus share count with wp_remote_post
- Why I can’t add a script-code into theme-settings without 403-forbidden?
- Is it wrong to put header tags inside WordPress help tabs? [closed]
- On Plugin Activation, How Do I Check for Proper Transport Mechanism?
- Want to make header and footer CMS driven sothat Editors can modify its content from wordpress admin section
- Facebook embeds loading the wrong language
- Page source contains an http item that makes page insecure; but in php files it’s written as https!
- Banner in WordPress
- How to convert this cURL to wp_remote_*?
- Creating dynamic header and footer files
- My header not showing up [closed]
- How to Access Script Tags in Header
- Problems accessing stylesheets/scripts loaded in WP header
- Rotate images in header based on date
- 404/500 error on content images if Referer header is from another domain [closed]
- How to add some lines to the wp-login.php header via functions.php?
- allowed_http_origins() only works in theme functions.php
- How to send a HTTP Post request using PHP Curl and WordPress
- Last-Modified header support doesnât speed up server processing – want more
- Insert stylesheet into WordPress header?
- Why are tags from the header showing up on my WordPress site? [closed]
- How to register and set http/2 server prefetch for a specific asset?
- Header with content
- WordPress Template not getting my Sub-Header File
- How to add social follow button to header? [closed]
- Include two headers
- Empty lines in header, how to remove them
- Benefits to using CSS for header image instead of html img tag [closed]
- Export Header and Footer
- Custom headers in WordPress, are there also custom footers?
- Inserting iframe right after on header.php
- Code needs wrapper/container to put footer back in, but where?
- How can I remove or change the tooltip of an icon
- Design Header meta on single posts wordpress
- Including PHP files in header.php
- Display values of current POST request on page
- Using a nonce Content Security Policy header for style-src for inline style elements returns errors
- How can I use an iframe element as my header media?
- How to make my banner (logo image) position on the center
- Inconsistencies between wp_remote_post and cURL
- Easiest way to use relative URLs in my WordPress header
- Should I use do_action in the header file?
- set cookies on certain page only
- Video Header in 2016 theme
- How do I change top header background color
- only header is showing up in posts
- force download a file in template_redirect hook
- video header in desktop view, image header in mobile view
- Force download of MP3 file in Safari
- throttle/limit a logged in user’s http requests to specific page on a per day basis
- show wordpress data without headers
- Override theme metadata in header
- Header Image instead of dynamic text
- Code to Show for One post only in head
- Download custom file in wordpress backend [duplicate]
- Removing old code from header
- Does WordPress perform better with curl installed?
- Random header image but also specific header for certain pages
- How to remove uncategorised posts from WordPress
- Dynamically changing header text depending on URL in WordPress html page
- After being hacked Fatal error: Call to undefined function get_header() in 404.php on line 1
- change headline of page
- making posts linked outside of WordPress still use the same header and footer
- How change the header color?
- How to remove lines over text using Phlox theme with Elementor Pro?
- Loading second header.php for other homepage showing double header.
- My CSS, footer and header don’t show up!
- End of script output before headers – multiple apache error_log errors
- Can you pass user/pass for HTTP Basic Authentication in URL parameters?
- wp_redirect problem using code snippets