• 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

Access relation of pivot table in Laravel

With doctrine ODM, can I embed many subdocuments in a main document?

Is there a way to correctly use sanitize_text_field and wp_unslash that doesn't cause psalm to error with "expects string, possibly different type"

Get sum of arrays inside array

Override default Auth routes in Laravel 7

PHP - CURL using HTTPS [closed]

Laravel s3 upload file with metadata using pre-signed url

Insert And Retrieve Data in MySQL with $.post Noob Question

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

PHPExcel export HTML table to xlsx

Magento 2 - Controller returning blank page

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

I want a way to give path to my files which are outside of public folder in laravel

Inserting data into SQL Server Db An Invalid direction was specified

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

About Contact Privacy policy Terms and conditions