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.

  • Just as without a header, only with a header. It is better to attach the code that you have already written to the question - Alexey Ten
  • one
    It is possible through curl , it is possible and through file_get_contents in the third argument. - ArchDemon
  • @ArchDemon Thank you, I figured it out further, everything helped! - Taras

1 answer 1

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);