• 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

I'm trying to use curl with php but getting this error:Could not resolve host: Bearer

Sum array values of a column within each column of an array with 3 levels

Transpose multidimensional array and join values with commas

Manage independently the decimal number of the price of each product [duplicate]

How to KeyBy where multiple items have the same key

PHP password_verify

Not able to access model in the controller mautic

laravel MVC execution flow

how to retrieve the first and last instance of a row in pdo dataset

How to Install Composer Require doctrine/dbal

Filter WooCommerce products with post__in and additional meta queries

How to add a custom field to all Woocommerce attribute terms using add_action

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

How to get unique slug to same post-title for other time too?

php echo remove slashes from url [duplicate]

About Contact Privacy policy Terms and conditions