Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use api token in header php

I am working on a project and I don't know how to use API using token.
I have token but

Site URL:- https://example.com/api This info is given on site:

To identify yourself you should include the following data on the beginning of your requests (header):

Header = Authorization Value = Token token=YOUR ACCESS TOKEN

How do I receive and send data from API using PHP?

like image 218
Maulik Lathiya Avatar asked Dec 06 '25 21:12

Maulik Lathiya


1 Answers

You can use cURL:

$crl = curl_init("https://example.com/api");

$header = array();
$header[] = 'Authorization: Value=Token token=<YOUR_ACCESS_TOKEN>';

curl_setopt($crl, CURLOPT_HTTPHEADER,$header);
$rest = curl_exec($crl);

curl_close($crl);

print_r($rest);
like image 156
xjmdoo Avatar answered Dec 09 '25 12:12

xjmdoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!