• 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 increase the PHP upload limits [duplicate]

WAMP Virtual Host not working

Chunk and transpose a flat array into rows with a specific number of columns

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

Call to undefined function openssl_decrypt

Why is this PHP array not the same?

SQL AVG() to 2 decimals

XML to CSV with PHP converter [problem with images grabing]

how to search for a file with php

Laravel: Why is my variable not being set while it's in the construct function of the controller?

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel

PHP array, move keys and values to new array, but mix it up

Laravel Jetsream Profile page not loading on fresh install

PHP array sort and remove duplicates by two field values

PHP if in_array() how to get the key as well?

About Contact Privacy policy Terms and conditions