• 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

Laravel csrf token mismatch for ajax POST Request

Saving Data from form to database using AngularJS and php

How to change product Image when variables are selected in Shop and Archive Pages?

How to send upload image through email

Vimeo API: how to save a vimeo into a subfolder?

Adding reCAPTCHA v2 into my PHP file

RuntimeException: Unable to create the cache directory (/var/www/sonata/app/cache/dev)

Laravel Route issues with Route order in web.php

How to execute sql code based on fetch array

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

WordPress Security Standards want me to escape my html, but how to do it correctly?

Combining a describing and one array with data

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

Detect a fetch request in PHP

Laravel Schedule not sending email

About Contact Privacy policy Terms and conditions