• 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

CSV to PHP class properties

Reorder attribute dropdown terms in Woocommerce single variable products

How can I stop a symfony process which is listening on http://127.0.0.1:8000

How to add automatically collapse/expand in content wordpress (single.php)?

php echo xml documents with header

Correctly determine if date string is a valid date in that format

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

PHP/HTML: Creating A SubMenu

Pass a select with mysqli_fetch_row to a table

Upgrade PHP on AWS Linux

printing all running session variable in laravel 5.1

PHP my timezone is no setting up in PHP.ini File in xampp

Can we define variables in `.tpl` files?

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

About Contact Privacy policy Terms and conditions