• 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

MongoDB Duplicate Documents even after adding unique key

Combining a describing and one array with data

Get orders by date and status woocommerce

How do I truncate a decimal in PHP?

Show only featured products in Woocommerce shop page

Edit product hook WooCommerce

PHP Download MP3 files from directory on server

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Transpose multidimensional array and join values with commas

How do I do HTTP basic authentication using Guzzle?

get attribute from class not working php 7

PHP array_filter with arguments

Must be of the type array, null given,

PHP Fatal error: Class not found - PHPUnit

How to add automatically collapse/expand in content wordpress (single.php)?

About Contact Privacy policy Terms and conditions