Answer the question
In order to leave comments, you need to log in
I can't get data using cURL, how to solve the problem?
I'm trying to get the page api.warface.ru/weapon/catalog
using Curl
. But the answer is empty. Please tell me what could be the problem? What's wrong?
<?php
$url = "http://api.warface.ru/weapon/catalog";
$user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36";
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$str = curl_exec($ch);
curl_close($ch);
print_r ($ch);
?>
Answer the question
In order to leave comments, you need to log in
In your curl you need to do json_decode. You are getting a Json object.
Or do this:
$json = file_get_contents('http://api.warface.ru/weapon/catalog');
$obj = json_decode($json);
var_dump($obj);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question