• 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 Install Composer Require doctrine/dbal

How to loop sql table data inside a html table

zsh: command not found: php

php code to send checkbox form results to email

woocommerce_wp_select options array from product attribute terms

CSS file not imported in laravel blade view

Auto increment id JSON

Display the WooCommerce product price inside a custom function

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

woocommerce change position of price

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Confirm Leave on External Links in Wordpress

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

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Mobile browsers are adding .html to filename on download

About Contact Privacy policy Terms and conditions