• 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

Laravel eloquent update record without loading from database

image source not readable

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

Show rotation of tweets using current day of month

Shortcode or PHP inside a shortcode in Wordpress

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

how to validate form data in codeigniter 4

Reorder attribute dropdown terms in Woocommerce single variable products

How to update array value in Laravel

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Required field only if another field has a value, must be empty otherwise

Custom add to cart button URL for specific product in WooCommerce?

HTML and PHP in one file

Search for array row with specific column value and return another value from qualifying row

SlimExceptionHttpNotFoundException

About Contact Privacy policy Terms and conditions