How to make a request in php with the addition of http header? A request for a link is required with the token in the http header. Thank you for attention.
1 answer
For example, through CURL
$headers = array( 'Content-Type: application/json', 'Token:'your_token') ); $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $api_url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($handle, CURLOPT_HTTPHEADER, $headers); curl_close ($handle);
|
curl
, it is possible and throughfile_get_contents
in the third argument. - ArchDemon