• 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

Saving Data from form to database using AngularJS and php

Laravel Blade checkbox not checked

how do i retrieve and display the alt text of an image in wordpress?

Assign output of PHP function to a variable

PHP date() with timezone?

Apply filter array/return terms

How to add a sidebar to Woocommerce Shop Page?

How to upload mpdf file after generating to s3 bucket in php

Magento 2 - How to add new block to admin panel in product page?

Laravel Carbon throws error The format separator does not match

Converting array to string and then back in PHP

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

How to KeyBy where multiple items have the same key

Laravel Livewire: jQuery not working in child component loaded via @if statement

Show date difference as "20" instead of "20 years ago"

About Contact Privacy policy Terms and conditions