• 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

Facebook API, get page post link (PHP)

php mysql + create a friend request system

Installing Composer - Internal Error

Having issue with matching rows in the database using PDO

PHPS source file - 403 Forbidden You don't have permission to access this resource

How to execute sql code based on fetch array

Laravel - Implicit route model binding with soft deleted data

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Add record for each array elements if missing in table

Manage independently the decimal number of the price of each product [duplicate]

Check If array is null or not in php

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

How to get multiple values with same key from an array PHP

Two buttons one form

How avoid Moved Permanently The document has moved here

About Contact Privacy policy Terms and conditions