• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

wp_remote_get() not passing authentication

phpwordpresshttp


PHP Snippet 1:

$wp_request_headers = array(
    'Authorization' => 'Basic ' . base64_encode( 'username:password' )
);

$wp_request_url = 'http://localserver/wordpress-api/wp-json/wp/v2/posts/52';

$wp_delete_post_response = wp_remote_request(
    $wp_request_url,
    array(
        'method'    => 'DELETE',
        'headers'   => $wp_request_headers
    )
);

echo wp_remote_retrieve_response_code( $wp_delete_post_response ) . ' ' . wp_remote_retrieve_response_message( $wp_delete_post_response );

Related Snippets

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Laravel query builder binding parameters more than once

Manage independently the decimal number of the price of each product [duplicate]

Failing validation doesn't stop code execution in livewire component

Adding one microsecond to Datetime object in PHP

How to find phpcs current default standard

Shortcode or PHP inside a shortcode in Wordpress

Sagepay Error The Vendor failed to provide a RedirectionURL

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Nginx RTMP not recording

laravel controller function parameters

Destroy session upon refresh

httpd.conf on Windows: can't locate API model structure `php8_module`

Laravel 5.2: Unable to locate factory with name [default]

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

About Contact Privacy policy Terms and conditions