Posted inProgramming / Mysql / Mysqli / php

PHP curl Http authentication header from Client

PHP curl Http authentication header from Client

Today, We want to share with you PHP curl Http authentication header from Client.
In this post we will show you HOW TO use Basic Authorization with PHP cURL, hear for PHP: HTTP authentication with PHP we will give you demo and example for implement.
In this post, we will learn about Set Http authentication header from Client — PHP / CURL with an example.

SMSpay Payment Gateway

SMSpay Payment Gateway used for to WooCommerce allows Norwegian merchants used to accept payments via mobile SMS on WooCommerce, using the Basic SMSpay.io service.

Invalid signature received for JSON Web Token validation

{“statusCode”:401,”error”:”Unauthorized”,”message”:”Invalid signature received for JSON Web Token validation”,”attributes”:{“error”:”Invalid signature received for JSON Web Token validation”}}

//ssl verifypeer
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//Set the simple content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

Sendipakainfo Auth in headers PHP curl : SMSpay documentation

 '[email protected]',
    'password' => 'pakainfo******'
);

//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);

//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);

//ssl verifypeer
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//Set the simple content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

//Execute the request
$result_data=curl_exec($ch);

// close cURL resource, and simple free up system resources
curl_close($ch);
echo "
";
print_r($result_data);
echo "

";
?>

PHP – Creating OAuth Authorization Header

";

$url="http://api.smspay.devz.no/v1/payments";

    $ch = curl_init();  
	$jsonDatapayements = array(
	
		'phone' => '+9198985698',
		'currency' => 'USD',
		'invoice' => '011',
		'shippipakainfo'=>'12500',
		'merchant' => $mid,
		'item_number_1'=>'985',
		'item_name_1'=>'Tools',
		'amount_1'=>'3585',
		'quantity_1'=>'10',
		'shippipakainfo_1'=>'148'
		);
	$jsonDatapay = json_encode($jsonDatapayements);
    curl_setopt($ch,CURLOPT_URL,$url);
	
	curl_setopt( $ch, CURLOPT_POST, count( $jsonDatapayements ) );
	
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	
	$header   = array();
	$header[] = 'Authorization: Bearer ' . $access_token;
	$header[] = 'Content-Type:  application/json ';
	
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDatapay);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $output=curl_exec($ch);
	
    curl_close($ch);
	
	echo "
";
	print_r($output);
	echo "

";
?>

View More..

We hope you get an idea about PHP curl Http authentication header from Client
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype