Allegro WebAPI

Programming interface of the Allegro platform

doGetCatsDataLimit

Last change: 07.03.2013 r.
Availability:
This method allows for loading in portions the full tree of categories available in the indicated country. 50 elements are returned by default. The size of portion can be regulated by the package-element parameter and the offset parameter allows to control the process of loading next portions of data.

  1. country-code | int | required
    Country identifier (a list of country identifiers can be loaded using the doGetCountries method).
  2. local-version | long | non-required
    Outdated parameter (it is required to enter any value appropriate for the parameter type).
  3. webapi-key | string | required
    User's WebAPI key.
  4. offset | int | non-required
    Parameter which allows for controlling loading of new data portions (portion numbers are indexed from 0).
  5. package-element | int | non-required
    Parameter which allows for defining a size of data portion (scope 1-5000; 5000 by default).



Sample structure of method call

$dogetcatsdatalimit_request = array(
   'country-id' => 1,
   'local-version' => 0,
   'webapi-key' => 'g2fe408289',
   'offset' => 1,
   'package-element' => 2
);

  1. cats-list | CatInfoType[]
    Array of structures containing information on each category.
    1. cat-id | int
      Category identifier.
    2. cat-name | string
      Category name.
    3. cat-parent | int
      Supracategory identifier (or 0 for main categories).
    4. cat-position | int
      Position of a category in comparison with other categories of the same tier (indexed from 0).
    5. cat-is-product-catalogue-enabled | int
      Outdated field (will always return 0).
  2. ver-key | long
    Version key value relevant for a selected country and WebAPI key provided
  3. ver-str | string
    Component version of a category's tree structure relevant for a WebAPI key provided.



Sample structure of server reply

$dogetcatsdatalimit_response = array(
   'cats-list' => array(
      array(
         'cat-id' => 19732,
         'cat-name' => 'Jewelry and Watches',
         'cat-parent' => 0,
         'cat-position' => 2,
         'cat-is-product-catalogue-enabled' => 0),
      array(
         'cat-id' => 73973,
         'cat-name' => 'Delicacy',
         'cat-parent' => 0,
         'cat-position' => 3,
         'cat-is-product-catalogue-enabled' => 0)),
   'ver-key' => 16551276,
   'ver-str' => '1.2.63'
);
 

  • ERR_INPUT_COUNTRY_ERROR
    Invalid country identifier (zero or empty value has been provided in the parameter).
  • ERR_NO_DATABASE
    Problems with Allegro database.
  • ERR_WEBAPI_EXPIRED
    Expiry date of WebAPI key has been exceeded.
  • ERR_WEBAPI_KEY
    Invalid value of WebAPI key or WebAPI key has been blocked.
  • ERR_WEBAPI_KEY_INACTIVE
    The WebAPI key has been deactivated (User Agreement not accepted).
  • ERR_WEBAPI_NOT_AVAIL
    Problems with Allegro WebAPI service.

Allegro is not to be held liable for consequences of using examples of the published code. It does not guarantee its correct operation either. The code you see serves as an example only and may contain errors.

#1 (24.04.2010 y.) / php (Author: danielnowacki)
  1. /**
  2. * Klient SOAP Allegro WebAPI
  3. *
  4. * @see http://allegro.pl/webapi
  5. * @see http://webapi.allegro.pl/uploader.php?wsdl
  6. *
  7. * @package Allegro/Client
  8. * @author Daniel Nowacki
  9. * @version 1.0
  10. */
  11.  
  12. <?php
  13. abstract class Allegro_Client_Abstract extends SoapClient
  14. {
  15. ...
  16. /**
  17. * Pobiera kategorie Allegro
  18. *
  19. * Jeżeli wszystkie wartości parametrów wejściowych zostaną ustawione na 0
  20. * to pobierze wszystkie kategorie.
  21. *
  22. * @see http://allegro.pl/webapi/documentation.php/show/id,46
  23. *
  24. * @param int $offset od tego przesunięcia zacznij
  25. * @param int $minCountElements pobierz miniamalnie tyle elementow
  26. * @param int $portionSize wielkość jednorazowej paczki
  27. * @return array kategorie serwisu
  28. */
  29. public function &getCatsData($offset = 0, $minCountElements = 0, $portionSize = 0)
  30. {
  31. $cats = array();
  32.  
  33. // liczba wszystkich kategorii
  34. $categoriesCount = $this->getCatsDataCount();
  35.  
  36. // przypadek - będą pobrane wszystkie dane, do tego jest oddzielna metoda
  37. if ($offset == 0 && $portionSize == 0 && $count == 0)
  38. {
  39. $cats = $this->doGetCatsData($this->config['country'], $this->getApiVersion(), $this->config['webapikey']);
  40. }
  41. else
  42. {
  43. if ($portionSize==0) throw new Exception('Portion size must be greather than 0');
  44. $elementCounter = 0;
  45.  
  46. while($elementCounter < $minCountElements) // jak nie pobrano wystarczajacej ilosci danych
  47. {
  48. // pobierz porcję danych
  49. $tmp = array_merge($cats, $this->doGetCatsDataLimit($this->config['country'], $this->getApiVersion(), $this->config['webapikey'], $offset, $portionSize));
  50.  
  51. if (empty($cats)) // w pierwszej interacji przypisuje pobrane kategorie do zmiennej
  52. {
  53. $cats = $tmp;
  54. }
  55. else // w każdej kolejnej łączone jest pole z kategoriami
  56. {
  57. // łączę tylko po polu listy kategorii
  58. $cats['cats-list'] = array_merge($cats['cats-list'], $tmp['cats-list']);
  59. }
  60.  
  61. $elementCounter += $portionSize;
  62. $offset++;
  63.  
  64. // warunek stopu
  65. if ($elementCounter >= $categoriesCount) break;
  66. }
  67. }
  68.  
  69. // zwraca tylko same opisy pol
  70. return $cats['cats-list'];
  71. }
  72. ...
  73. }