• 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

Add rows to Single product Additional information table in WooCommerce 3.6

Normalize DateInterval in PHP

Appending data to an anchor tag

Login if user is active using Laravel Breeze

I want to store data in new index as per my key in php [duplicate]

laravel sanctum Route [login] not defined

Woocommerce redirect after add-to-cart error

How do I enable error reporting in Laravel?

500 Internal Server Error on Ajax request. Not sure the origin of the problem

How avoid Moved Permanently The document has moved here

Cannot connect to own websocket server when on secured domain

How to create a individual template for page or post in custom plugin?

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

PHP echo values of all sub keys [duplicate]

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

About Contact Privacy policy Terms and conditions