• 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

Results page in other window

Need to display only array value in JSON output

Yii2 select2 database exception number of bound variables does not match number of tokens

PhP how to calculate moments with variables rows

jQuery Ajax Post with data

How to get multiple values with same key from an array PHP

PHP date() with timezone?

How do I set the maximum php memory limit

Get orders by date and status woocommerce

How to get array values using foreach in laravel

How to get quarter for future date using Carbon?

HTTP Range requests with php for Video Embedding for solving going to specific time in video (seek bar not work)

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Last order would be re-order in wooCommerce. How is it possible?

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

About Contact Privacy policy Terms and conditions