• 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

Error Class "LaravelFortifyFeatures" not found

MySQL - Connection failed: No route to host

How to add a sidebar to Woocommerce Shop Page?

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

Telegram bot doesn't answer

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Testing subscription renewals on Stripe

Lumen - Postgresql setup - Composer

PHP date() with timezone?

Twig - How to check if variable is a number / integer

Remove categories with all childs derived from parent category

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

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

Dropdown with current value from Mysql

About Contact Privacy policy Terms and conditions