• 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 a custom text for a particular product on specific email notification in Woocommerce

Error Class "LaravelFortifyFeatures" not found

PHP drop down list using array's and foreach (else and for) code

How to create a video stream from a single dynamic image in PHP

Check If array is null or not in php

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Why does array_map() with null as callback create an "array of arrays"?

Laravel PackageManifest.php: Undefined index: name

PHP: Insert marker every 3 iterations

How can I stop a symfony process which is listening on http://127.0.0.1:8000

Composer Script echo

wp_remote_get() not passing authentication

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

using random function but it's displaying duplicates

PHP's array_map including keys

About Contact Privacy policy Terms and conditions