A
A
Alexey Dmitrievich2021-10-08 15:02:16
PHP
Alexey Dmitrievich, 2021-10-08 15:02:16

What is the correct way to get JSON through PHP?

Good afternoon. Please tell me what could be. There is a click

link , there is data output using json. But the problem is, I can't get them. Not with file_get_contents, nor with cURL. When I try to get data from other links (I found a bunch of examples in Google), I get data. I can't from this link. What could be the problem ? How should json be output so that it can be easily parsed later? UTF8 encoding, which headers I didn't specify, both text/html and application/json. That's all he doesn't want. Who faced, and can give advice?


Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
My joy, 2021-10-08
@t-alexashka

Something with your php settings. I'm ok with this url:

<?php

$url = 'http://195.78.42.246:3434/upp_shum/hs/vsAerostar/GetClients';
$response = file_get_contents($url);
$json = json_decode($response);
print_r($json);

issues
response
stdClass Object
(
[Clients] => Array
(
[0] => stdClass Object
(
[phone] => 380551256165
[email] => [email protected]
[password] => password
[number] => 35023058
)
[1] => stdClass Object
(
[phone] => 380999888888
[email] => [email protected]
[password] => password123
[number] => 35023058
)
[2] => stdClass Object
(
[phone] => 380555444444
[email] => [email protected]
[password] => pass
[number] => 41494252
)
[3] => stdClass Object
(
[phone] => 382222222221
[email] => [email protected]
[password] => 112233
[number] => 30594998
)
)
)

T
ThunderCat, 2021-10-08
@ThunderCat

The first thing to check is whether the given url is opened from the machine (for example, from wget), if the console is available, or by executing commands from php. Well, or as an option - turn on verbose in curl and see what's going on there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question