• 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

Clients authentication and user authentication with laravel

Read users and passwords from a txt file

IlluminateDatabaseQueryException could not find driver [duplicate]

Insert a DIV after the 6th product only once in WooCommerce category archives

What is my SQL missing?

How to change HTML structure inside WP <head>

Creating command to backup MySql database in Laravel

virtctl works when executed via command line but not from php exec()

GuzzleHttp Hangs When Using Localhost

Laravel views are showing from cache on one server but works fine on other server

Show Custom Data in Woocommerce Order Details Admin Area

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

PHPExcel How to set conditional formatting to change cell background color based on cells values

Get image type from base64 encoded src string

How to make Canonicals with PHP

About Contact Privacy policy Terms and conditions