• 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

how to redirect the user back to desired URL after login page in PHP?

phpunit - testing is painfully slow

Is there a way to use Foundry Model for Authentification inside Functional Tests?

What is my SQL missing?

Adding the custom page with add_menu_page function on Wordpress

Laravel MSSQL Server Connection not working

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Symfony there are no commands defined in the "make" namespace

XDebug not working in VScode for php debugging

Why isn't my PHP exception working?

Facebook PHP SDK - will not logout properly

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

PHP how to detect if running on arm64 cpu?

Laravel Unknown Column 'updated_at'

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

About Contact Privacy policy Terms and conditions