• 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 curl_exec() Connection refused when retrieving a remote image

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Message: Set sys_temp_dir in your php.ini after installed composer

how to use extended ASCII instead of unicode in PHP

Trying to iterate over a mongodb cursor twice - failing

Creating Combinations of Elements

Nginx disallowing execution of PHP in uploads directory with Magento

PHP usort() order in case of equality

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

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

Update Order custom Field value with WooCommerce REST API

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Unable to run composer install

Getting public posts of a random user from Facebook API

Sort multidimensional array by column value within a column

About Contact Privacy policy Terms and conditions