• 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

how to create html table in php

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

How to set dynamic `home` and `siteurl` in WordPress?

Adding reCAPTCHA v2 into my PHP file

MySQL - Connection failed: No route to host

How to create a individual template for page or post in custom plugin?

How to pass data to all views in Laravel 5?

How to send parameters in soap request in php in __soapcall() function

PHP block shortcut in Visual Studio Code

How update php.ini on a Mac OS X Mojave?

Form repeater send wrong data with last element in Laravel

Yii2: How do I debug console commands?

Coinpayments create_transaction "ERROR: Invalid command!"

How to remove Deprecated SymfonyComponentDebugDebugClassLoader?

Yii2 redirecting to previous page after login

About Contact Privacy policy Terms and conditions