• 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

PHP-Sort array based on another array?

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

WooCommerce Additional Information - if empty, hide

Laravel post contact form giving me error 419

Extract string between first whitespace and last whitespace in php

XML to CSV with PHP converter [problem with images grabing]

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

I want to display a sweetalert after the inserting of data in my database

php echo xml documents with header

wordpress : How to specify the cause "This site can’t be reached"

Whats the point of running Laravel with the command 'php artisan serve'?

PHP Deprecated issue when running artisan command

How to make autocomplete work in foreach php loop? (vscode, intellisense)

oauth-private.key does not exist or is not readable

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

About Contact Privacy policy Terms and conditions