dimanche 6 octobre 2019

Php Rest API: problem creating an array separated with ampersands

I have a doubt: An api requests the following structure:

API endpoint

● Production:

https://api-cbt.mercadolibre.com/api/orders/search/?days=<recentdays>&status=<order_status>&page=
<pageno>&access_token=xxx

● HTTP Method: GET

● Content-type header: content-type:application/json

Consequently I created the following structure:

        $variables = [];
        $variables['days'] = 10;
        $variables['page'] = 1;
        $query = $meli->get('/api/orders/search/', $variables, array('access_token' => $token));

but for some reason gives HTTPCODE = 401 (this is because $variables and commas are not been considered properly, I know that because access_token work perfect with other API calls).

My main question is what I have to do in order to produce a result like days=&status=&page=.. Im confused because I expected an array to be considered in that way but its not what is going on in my experience.

thanks in advance..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire