Tag Archives: Content Type

Use Multiple Headers in a PHP

With PHP, you can send multiple HTTP headers with file_get_contents() . you can also send information such as HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, and HTTP_CONNECTION with file_get_contents(). In this post, I have write a complete example code to set multiple headers; an Authorization header and a Content-Type header using PHP and make POST request using file_get_contents(). <?php $options = [“http” => [ “method” => “POST”, “header” => [“Authorization: token ” . $access_token, “Content-Type: application/json”], “content” => $data ]]; $context = stream_context_create($options); ?> Now […]

Compress JSON data

JSON is good data format to grab some server side data through an AJAX call. For example by using jQuery.ajax method. In PHP, to provide data in JSON format in super simple. However, when the data is large, do you know any ways to compress the data to facilitate for fast transmission. JSON – JavaScript Object Notation Here is a simple tutorial to introduce how to use format data in JSON format in PHP. First, you need to set the […]