• 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

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

protect images from being copied

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

Get image type from base64 encoded src string

Show rotation of tweets using current day of month

The sum of the user's points

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Warning: sqlite_query() expects parameter 1 to be resource, string given

Can't call javascript alert alertify library from PHP

cakephp save drag and drop list order to database

Reload parent page after submit in iframe

Laravel 5 issue with wherePivot

selected value from the listbox in php

PHP web3 ERC20 token function call

Not able to override collapsible.js in magento 2

About Contact Privacy policy Terms and conditions