Skip to content

Tag: http-headers

Sending Link Headers for Early Hints in PHP

Cloudflare has introduced Early Hints based on Link Header. I am a little bit confused about how I should send the link header in my PHP script. As I understand, I should send the Link Header for the links to preconnect I think we can send HTTP 103 Early Hint via PHP headers Is it enough? Answer No, you actua…

Retrieve data from CURL “-d” using PHP

This question is not about how to use CURL in PHP. But how to retrieve data that send using CURL with “-d” option. This command: curl -H ‘Content-Type: text/plain; charset=utf-8’ -d ‘Hello, World!’ -X POST http://localhost:8080 will produce empty array in $_POST variable. D…

how to force space to %20 in http_build_query?

I am facing a problem, that the API endpoint expects one of parameters with %20 replacing one of the spaces. Example: If I write ‘scope’ => ‘api offline_access’ the space gets translated to + sign when passing it to http_build_query() function. If I keep it like it is above, the sig…

How return http_code 401 with PHP

I’m using cUrl in the client side. On my webservice (ws.php), i’ve this simple code : When i call this ws.php page, i still have http_code = 200. Here is my cUrl code is client side : $code = 200 even i put the header code “401”. Answer try this on your ws.php: Let me know if this work…

How to pass custom header to RESTful call?

There are some web service APIs that I need to connect to for my website. Most of the APIs involve something like this: But one web service requires the API key to be set in a custom HTTP header. How do I make the request to this API url and pass the custom header at the same time? Answer You