• 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

codeigniter 4 running error first time with xampp

MongoDB Duplicate Documents even after adding unique key

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

file_get_contents() without "Http" to access external URL [closed]

How to auto populate preferredCountries from intl-tel-input with db output

Fetch files from next cloud storage and display in Laravel website

Filter WooCommerce related products by Polylang language

How to extract price from given url using Xpath?

PHP array_filter with arguments

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

How can I get data from PHP to Android TextView?

Reducing authentication calls on external API (Laravel 5.6)

How to render html from a @foreach loop in a textarea

Add and update products to session cart in Laravel

Check if my GET request has Header: Token

About Contact Privacy policy Terms and conditions