• 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

Explain how this array transposing and flattening function works

How to fix bootstrap multiselect search data using ajax

How to debug in WooCommerce 3+

Having issue with matching rows in the database using PDO

Popup Window and PHP form

Pass a select with mysqli_fetch_row to a table

How in Laravel run JavaScript code stored in php variable?

LARAVEL: How to fetch id dynamically in a query builder?

how to youtube api data to print in toolset metabox using a button click before save-post

Unable to Edit config.inc.php

Add a custom text for a particular product on specific email notification in Woocommerce

How to run or debug php on Visual Studio Code (VSCode)

Google Calendar API batch request PHP

(Laravel) How to delete multiple models including optional relationships?

How to make a array inside array?

About Contact Privacy policy Terms and conditions