A
A
Anton2016-11-01 11:04:39
PHP
Anton, 2016-11-01 11:04:39

How to parse goods?

Hello. I have such a page, on which goods are loaded by a post request from here hobbygames.ru/?route=lib/feed/products with such data.
I'm trying to get like this

$postdata = array(
        'saveState' => true,
        'state' => array(
            'page' => 10,
            'sort' => 'no_sort',
            'order' => 'ASC',
            'all' => true,
            'excluded_products' => [34580],
            'excluded_categories' => [27610, 26879, 26993, 27916],
            'results_per_page' => 100
        )
    );

    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/json; charset=utf8',
            'content' => $postdata
        )
    );

    $context  = stream_context_create($opts);
    $result = file_get_contents('http://hobbygames.ru/?route=lib/feed/products', false, $context);
    print_r(json_decode($result)->rendered);

As you can see, there is a page parameter that is responsible for the page with products, but when I change it, nothing happens, I still receive products from the first page, the same trouble with 'results_per_page' (the number of products on the page).
Please tell me what am I doing wrong?
curl -i -X POST -H "Content-Type: application/json" -d "{"saveState":true,"state":{"page":2,"results_per_page":100,"sort":"no_sort","order":"ASC","all":true,"excluded_products":[34580],"excluded_categories":[27610,26879,26993,27916]}}" http://hobbygames.ru/?route=lib/feed/products

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Reitarovskiy, 2016-11-01
Reytarovsky @Antonchik

I decided on my own, it was necessary to convert post data to json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question