1
Well, what I intend to do is relatively simple:
I intend to copy the entire code from this link:
http://steamcommunity.com/profiles/76561198337627631/inventory/json/730/2/
And save to a txt file.
How can I do this with PHP?
Thank you.
1
Well, what I intend to do is relatively simple:
I intend to copy the entire code from this link:
http://steamcommunity.com/profiles/76561198337627631/inventory/json/730/2/
And save to a txt file.
How can I do this with PHP?
Thank you.
2
You can do with Curl like this:
<?php
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://steamcommunity.com/profiles/76561198337627631/inventory/json/730/2/');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'MOZILLA YOOO');
$page = curl_exec($curl_handle);
curl_close($curl_handle);
$f_handler = fopen('test.txt', 'w');
fwrite($f_handler, $page);
And with file_get_contents:
<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"User-Agent: Mozzila yooo\r\n"
)
);
$context = stream_context_create($opts);
$page = file_get_contents('http://steamcommunity.com/profiles/76561198337627631/inventory/json/730/2/', false, $context);
$f_handler = fopen('test.txt', 'w');
fwrite($f_handler, $page);
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Miguel, with file get Contents, it’s not working.
– Gonçalo
What a mistake it makes?
– Miguel
Just don’t write anything down.
– Gonçalo
And Curl writes down?
– Miguel
No, you’re not writing.
– Gonçalo
Do you have a visual on the bugs? what gives me sometimes is error 429: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes which are too many request from the same client. Try changing the url, or wait a few minutes
– Miguel