• 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

How do I pass the dynamic output of a php variable or php function to a CSS variable?

How to override htaccees file for cache control header

phpunit - mockbuilder - set mock object internal property

Adding Multiple Custom Post Types in Wordpress

how to identify the web server name of remote host

How to find phpcs current default standard

Warning: sqlite_query() expects parameter 1 to be resource, string given

PHP: How to quickly split a key=value file into associative array

PHP only Hit Counter?

How to convert time from one timezone to another in PHP

How to identify whether webp image is static or animated?

Create a new line whenever an array value reaches more than 10 characters

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

How to convert the int value to inch in PHP [closed]

Object of class stdClass could not be converted to string error

About Contact Privacy policy Terms and conditions