• 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

How to debug in WooCommerce 3+

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

Sentry on Symfony: how to exclude `NotFoundHttpException`

Laravel: HTML in notification

PHP Imap , php 7.4.3 on mac osx catalina

Phpunit partial mock + proxy Entity

how to remove white space in select 2

Only on Firefox "Loading failed for the <script> with source"

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

php 7 php.ini upload_max_filesize not working

Merge key and value of array index [duplicate]

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

retrieve data from database using session

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Laravel Get Days In Month From Month Number?

About Contact Privacy policy Terms and conditions