• 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

Implode columnar values between two arrays into a flat array of concatenated strings

Composer Warning: openssl extension is missing. How to enable in WAMP

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

wordpress function breaks wp-admin

How to get Laravel's CSRF Token from Another Website?

How to override header set in Apache config with more specific header in a virtual host

How to install ZeroMQ for PHP on an Alpine Linux container?

Destroy session upon refresh

PHP array stringify

Issue with laravel eloquent model property

auth pages not getting css in laravel

how to create html table in php

Using array_intersect on a multi-dimensional array

add_action() function in wordpress not working [duplicate]

Split comma separated value from table column into rows using mysql?

About Contact Privacy policy Terms and conditions