• 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 to insert data from multiple select dropdown values into database?

How can I pass the list to the component variable in Laravel?

Is there a way to use Foundry Model for Authentification inside Functional Tests?

Symfony run hint kernel.secret parameter not found

How can i call a function that executes an fpdf based on the choice of a form selector?

How to loop a tree array with unknown depth and get array blocks?

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Create a zip file and download it

PHP mail function is sending blank message body

Match single unknown parameter php (Morse-code Regex)

Converting array to string and then back in PHP

get folder directory from input type file - PHP

How to create a scheduler application in php

curl returning 301 error after migrating to https

Match csv filenames to table names and import

About Contact Privacy policy Terms and conditions