• 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

Printing more than one array using print_r or any other function in php

How to create custom authentication in laravel 8?

laravel automatically deletes server.php on php artisan serve

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Only on Firefox "Loading failed for the <script> with source"

httpd.conf on Windows: can't locate API model structure `php8_module`

jQuery Ajax Post with data

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

how to insert data into select2 search input after scan using qrcode

woocommerce change position of price

CodeIgniter 3 is generating a session file on each request, why?

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

Multiply each value in array using array_map function

PHPUnit (Phar) Fatal Error Only When Test Fails

About Contact Privacy policy Terms and conditions