• 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

WooCommerce - unset "<product> removed notice…" on cart page

Extract string between first whitespace and last whitespace in php

Wordpress 'post_type_link' hides permalink

Laravel MSSQL Server Connection not working

How to get page number on dompdf PDF when using "view"

str_replace or preg_replace random number from string

PDOException SQLSTATE[HY000] [2002] No such file or directory

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

php echo remove slashes from url [duplicate]

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How can I make Laravel return a custom error for a JSON REST API

Google API Heatmap Layer exception, why?

How to make Canonicals with PHP

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

How To Access A Column In M-M Relationship Table In Laravel

About Contact Privacy policy Terms and conditions