• 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

Getting output of MS stored procedure on php call

Querying only one row from a one to many relationship laravel

CodeIgniter 3 is generating a session file on each request, why?

Laravel websockets AWS EC2 - Connection failed

How to add automatically collapse/expand in content wordpress (single.php)?

How to put php code inside opening and closing shortcodes

get folder directory from input type file - PHP

Display Link Title Instead of URL in XSL

Performance of foreach, array_map with lambda and array_map with static function

Get WooCommerce product variation attribute terms in admin products general box

Laravel phpunit test failing authorization

JSON Render Issue in Date Object Laravel and PHP 7.4

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

possible options to create pdf file using html elements to generate invoice in php and codeigniter

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

About Contact Privacy policy Terms and conditions