• 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

Unable to get password for the instance created from AMI

Change user role if checkout custom checkbox is checked in WooCommerce

Display a success custom notice after Placing an Order in WooCommerce

How to fix bootstrap multiselect search data using ajax

Yii2: How do I debug console commands?

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

How to write PHP in XSLT

No definition found for function in vendor vscode

Select option from dropdown menu with PHP and mySql

stay with the last 15 elements of an array [duplicate]

How to keep value of selected value after form submission?

Google API Heatmap Layer exception, why?

Unable to run composer install

Converting IPv6 to IPv4 address in PHP

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

About Contact Privacy policy Terms and conditions