• 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

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Increase value by 1 on button click

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

The sum of the user's points

php curl requesting twice

Cut an arabic string

xdebug 3 not working in ubuntu 20.04 with docker

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Clients authentication and user authentication with laravel

Can't exclude directories from .htaccess mobile redirect?

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"

how to loop through json response data using ajax jquery?

How to get the total hour from starting time to end time in php

How to unlink image from folder?

About Contact Privacy policy Terms and conditions