• 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

Saving Data from form to database using AngularJS and php

Object of class stdClass could not be converted to string error

Warning: A non-numeric value encountered

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

OctoberCMS / Anonymous Global Scope

send email using gmail-api and google-api-php-client

Dynamic table in HTML using MySQL and php

Laravel 5 issue with wherePivot

Laravel csrf token mismatch for ajax POST Request

How to use PHPCBF to fix one issue at a time?

How to convert a carbon into string, to take the date only?

image source not readable

Applying programmatically a coupon to an Order in WooCommerce3

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

About Contact Privacy policy Terms and conditions