• 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

IlluminateDatabaseQueryException could not find driver [duplicate]

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Passing a boolean value from checkbox in Laravel form

How to downgrade or install a specific version of Composer?

Insert a DIV after the 6th product only once in WooCommerce category archives

Render the content of default_filter.php in Joomla front-end

PHP Discord OAUTH2 code sample not working

Multiple order by in WooCommerce

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

Limit of log line written to Apache Errorlog from mod php error_log

How do I remove this delivery notification from here?

MongoDB Duplicate Documents even after adding unique key

Unit (real unit test) of test laravel relationship

Change user role if checkout custom checkbox is checked in WooCommerce

About Contact Privacy policy Terms and conditions