What is the reason of failure in parsing url?

0 like 0 dislike
133 views
I do not know how to put the question.

Using cURL from a JSON source, get a catalog and keep the goods in your base.

Faced with the inexplicable problem, the parsing of URLs behaves differently, despite the fact that the difference in the url is just one number, example:

site.ru/market/ware?page=1&category=1
and

site.ru/market/ware?page=1&category=11

The second link, more precisely parsing it works 100%, parsing the first link does not want to work, although the content of JSON is completely identical.

The whole day could not understand why, the cause was determined only by iterating through the addresses above.

Tell me what could be the problem, what category=1 does not want to work?

Thought about a way you can change url to parse from category 1, could not think of anything.

The room is inserted so

for ($page = 1; $page <= 50; $page++) { $item = $ware->getMarket('1', $page);

...
Class

$response = (array)@json_decode($this->request('GET', 'http://site.ru/market/ware?page=' . $page . '&category=' . $category)['body'], true);


or so (tried it in different ways, the result is the same)

$response = (array)@json_decode($this->request('GET', 'http://site.ru/market/ware?category=' . $category . '&page=' . $page)['body'], true);


I think the reason is that the category is designated by one digit, all categories with two digits or letter designation function correctly from 1 to 9 not working.
by | 133 views

1 Answer

0 like 0 dislike
although the content of JSON is completely identical.

That's straight right? Or is it so private?
It would be worthwhile to throw somewhere structure.

If the answer comes normal then the problem is in JSON. Tried to json_error and understand what's the problem?

p.s lead to the type and pressure error is not the best solution, the first so generally useless there and so will return an array (if you normally proprit JSON, of course)

In PHP 7.3 introduced to handle the error JSON exception JsonException if the version allows, you can wrap it in a try - catch block.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
asked Sep 4, 2019 by RaymanPy
0 like 0 dislike
3 answers
asked Aug 9, 2019 by RaymanPy
0 like 0 dislike
3 answers
asked Jul 17, 2019 by RaymanPy
110,608 questions
257,187 answers
0 comments
40,796 users