• 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

Laravel Blade checkbox not checked

What is my SQL missing?

Converting array to string and then back in PHP

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Display Link Title Instead of URL in XSL

How to get company posts from LinkedIn via API?

CodeIgniter extend CI_URI undefined method

Laravel 5.2: Unable to locate factory with name [default]

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

How to install ZeroMQ for PHP on an Alpine Linux container?

How to remove from a multidimensional array all duplicate elements including the original?

Form repeater send wrong data with last element in Laravel

401 Unauthorized only occurring on some pages in Laravel 8

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

Laravel no logout option from menu after successfull login

About Contact Privacy policy Terms and conditions