• 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

php echo remove slashes from url [duplicate]

Wordpress wpdb->delete issue

how to upload binary image to sql server using php laravel

How to average columns of data from multiple, flat arrays?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Why isn't my PHP exception working?

PHP error: "The zip extension and unzip command are both missing, skipping."

Statement that checks whether a URL contains a particular path?

With doctrine ODM, can I embed many subdocuments in a main document?

Laravel-fopen: failed to open stream: Permission denied

Printing more than one array using print_r or any other function in php

PHP array slice from position + attempt to return fixed number of items

Add customer email and phone in "Order" column to admin orders list on Woocommerce

JSON Render Issue in Date Object Laravel and PHP 7.4

Wordpress how to get the post thumbnail inside a figure tag

About Contact Privacy policy Terms and conditions