• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

file_get_contents() without "Http" to access external URL [closed]

php


PHP Snippet 1:

<?php

$ctx = stream_context_create(array(
    'http' => array(
        'timeout' => 16.0 // seconds
    )
));

$contents = file_get_contents('http://...', FALSE, $ctx);

// do something with $contents

PHP Snippet 2:

$ ./test
{
  "headers": {
    "Host": "httpbin.org"
  }
}

$ cat test
#!/usr/bin/env php
<?php

die(file_get_contents('http://httpbin.org/headers'));

Related Snippets

Issue saving card for customer

php echo xml documents with header

Cannot connect to own websocket server when on secured domain

PHP Include for HTML?

Get all WooCommerce products within own plugin

SlimExceptionHttpNotFoundException

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

How to get company posts from LinkedIn via API?

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Target class controller does not exist - Laravel 8

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

How to submit the custom form data in database in WordPress without plugin using ajax?

Display the default discounted price and percentage on Woocommerce products

How to install php yaml on CentOs?

Live search query using JS and PHP for QA forum

About Contact Privacy policy Terms and conditions