i'm attempting access external url (api)
echo file_get_contents("http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=4798"); however, want request url without "http://" - causes run slower, (not sure why). if remove http:// parameter can't find file (understandably)
any ideas?
@jack-hardcastle, based on comments below question: try increase timeout.
tried load url provided in chrome on machine , after big while of loading, showed me probably correct response.
here's how increase http timeout file_get_contents():
<?php $ctx = stream_context_create(array( 'http' => array( 'timeout' => 16.0 // seconds ) )); $contents = file_get_contents('http://...', false, $ctx); // $contents i tried find out missing headers runescape services may check; wrote simple script sending simple get request against httpbin.org:
$ ./test { "headers": { "host": "httpbin.org" } } $ cat test #!/usr/bin/env php <?php die(file_get_contents('http://httpbin.org/headers')); suprise: header sent file_get_contents() host. there might in headers missing runescape services.
Comments
Post a Comment