• 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

"Unable to load dynamic library 'pdo_sqlsrv.so' "Cenos7 PHP7.2.10

PHP Warning: Module already loaded in Unknown on line 0

How to install PHP composer inside a docker container

Fetch files from next cloud storage and display in Laravel website

Add customer email and phone in "Order" column to admin orders list on Woocommerce

how to identify the web server name of remote host

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

could not find driver Debian SQL Server PHP

Google Gmail API - How to login programatically?

How to insert Google Adsense Code in PHP script?

How to show selected value using javascript in laravel

Laravel unique validation on multiple columns

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

php file upload scanning using clamav, permissions on /tmp/

how to pass row id in href of a tag in codeigniter controller?

About Contact Privacy policy Terms and conditions