• 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

str_word_count() function doesn't display Arabic language properly

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

how to fix Service provider class not found when using repository?

Laravel Schedule not sending email

how to identify the web server name of remote host

Change user role if checkout custom checkbox is checked in WooCommerce

PHP - CURL using HTTPS [closed]

Group data in a multidimensional array based on two columns

Laravel print last executed SQL query with Query log

file_put_content...fail to open stream:Permission denied in Laravel 5

How to loop sql table data inside a html table

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

how can I set a session variable in Drupal 8 and get it in a php script?

PHP rotate matrix counter-clockwise

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

About Contact Privacy policy Terms and conditions