Skip to content

Instantly share code, notes, and snippets.

@Studiodews
Studiodews / getting-remote-json-data-with-the-fetch-api.markdown
Created August 13, 2020 19:03
Getting remote JSON data with the fetch API
@avtaniket
avtaniket / cors.php
Last active July 11, 2024 16:40
Handle CORS in PHP
<?php
/* Handle CORS */
// Specify domains from which requests are allowed
header('Access-Control-Allow-Origin: *');
// Specify which request methods are allowed
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
@vyspiansky
vyspiansky / set-user-agent-file_get_contents.php
Last active April 25, 2024 08:39
PHP: set user agent using file_get_contents()
<?php
$options = array('http' => array('user_agent' => 'custom user agent string'));
$context = stream_context_create($options);
$response = file_get_contents('http://domain/path/to/uri', false, $context);