• 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

Call to undefined function openssl_decrypt

Laravel/docker-compose/redis - Class 'Redis' not found

How to make dot match newline characters using regular expressions

How to convert a carbon into string, to take the date only?

nginx err_connection_refused, can anyone help me?

How do I remove this delivery notification from here?

How to retrieve Active Directory group policy maximum password age using LDAP

Change the alert text on add to cart action without selected variation in Woocommerce

How to run a shell as root from php (apache)

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

Convert date and time to Jalali in Laravel

PHP Warning: Module already loaded in Unknown on line 0

Coinpayments create_transaction "ERROR: Invalid command!"

Laravel print last executed SQL query with Query log

Group data in a multidimensional array based on two columns

About Contact Privacy policy Terms and conditions