• 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

Stop caching for PHP 5.5.3 in MAMP

best way to store error messages in Laravel (session or variable)

how to use extended ASCII instead of unicode in PHP

Warning: A non-numeric value encountered

PHP function Not Working As Expected From functions.php Include File

How to convert a carbon into string, to take the date only?

Unit (real unit test) of test laravel relationship

Required field only if another field has a value, must be empty otherwise

javascript html popup window

Symfony run hint kernel.secret parameter not found

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

Detect emoticons in string

how to prevent float variables displaying as scientific notation when printing [duplicate]

Parsing JSON File to array in PHP

Respond with status code 401 on authentication failure using Laravel and Passport?

About Contact Privacy policy Terms and conditions