• 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 can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Custom API and cunsuming in php?

Apply session id from request header

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Required field only if another field has a value, must be empty otherwise

Additional price based on cart item count in WooCommerce

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

Smarty if isset

Symfony redirect if already loggedin from login page

How do I call Validator from a namespace with an already existing Validator class

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

Check if my GET request has Header: Token

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

How to set time with DateTime modify?

WHERE IN array binding in DB::raw laravel 5.4

About Contact Privacy policy Terms and conditions