• 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

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

phpapicurl


PHP Snippet 1:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,  CURLOPT_RETURNTRANSFER, 1);


$headers = array(
   "X-Custom-Header: value",
   "X-Custom-Header: value"
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    

$output = curl_exec($ch); //Call your api at end

Related Snippets

Sliders in Laravel

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

PHP mail sending empty mails

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Results page in other window

Attempted to call an undefined method named "get" of class "MailController"

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Yii Ajax Submit button

PHP Warning: Module already loaded in Unknown on line 0

Limit WooCommerce products in cart only from one custom taxonomy

Parsing JSON File to array in PHP

Check if my GET request has Header: Token

Assign output of PHP function to a variable

How to read laravel_session cookies saved in cookie memory of browser in client side?

wordpress function breaks wp-admin

About Contact Privacy policy Terms and conditions