• 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

Sort a multidimensional array by integer inside of a string value which is two levels down

Can I use a WooCommerce function without any WooCommerce page?

Get orders by date and status woocommerce

Laravel 5 issue with wherePivot

PHP: Insert marker every 3 iterations

PHP Fatal error: Class not found - PHPUnit

Get image type from base64 encoded src string

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

How to make dot match newline characters using regular expressions

Clear javascript source cache laravel 5.8

Wordpress how to get the post thumbnail inside a figure tag

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

how to pass row id in href of a tag in codeigniter controller?

How to change product Image when variables are selected in Shop and Archive Pages?

About Contact Privacy policy Terms and conditions