• 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 to make Canonicals with PHP

How to change 'users' auth table and use another instead Laravel

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

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

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

How do I enable error reporting in Laravel?

Hide specific products from unlogged users based in product category in WooCommerce

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

Server-sent events in PHP (without echo or print)

Getting values for an enum?

Problem with fetching data from database in Laravel

array_map triple dimensional array [duplicate]

PHP usort() order in case of equality

Composer Script echo

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

About Contact Privacy policy Terms and conditions