Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SOLVED] pobieranie aukcji przez api i paginacja
Aquarius
post
Post #1





Grupa: Zarejestrowani
Postów: 36
Pomógł: 1
Dołączył: 18.10.2008

Ostrzeżenie: (0%)
-----


witam,
udało mi się przerobić po wielu bojach starą metodę pobierania informacji o aukcjach na nową (w końcu zrozumiałem czemu ktoś w internecie napisał że to Allegro API to koszmar programisty), nie otrzymuję już błędów przy pobieraniu informacji, mam jednak problem z paginacją (stronicowaniem), załączam cały kod, być może przyda się komuś do przejścia na nową metodę:

  1. $offset = ($_GET['id']) ;
  2. $limit = 12;
  3. $soap = new SoapClient('https://webapi.allegro.pl/service.php?wsdl', array('trace' => true));
  4.  
  5. $items = $soap->doGetItemsList(
  6. 'webapiKey' => 'XXXXXXXX',
  7. 'countryId' => 1,
  8. 'filterOptions' => array(
  9. 'filterId' => 'userId',
  10. 'filterValueId' => array('XXXXXXX')
  11. )
  12. )
  13. )
  14. );
  15.  
  16. $items = get_object_vars($items);
  17. $ile_stron = $items['itemsCount'] / $limit;
  18. $pag = floor($ile_stron);
  19. if ($offset >= "1") {
  20. $back = ($_GET['id'] - 1);
  21. }
  22. else {
  23. $back = $pag;
  24. }
  25. if ($offset != $ile_stron) {
  26. $next = ($_GET['id'] + 1);
  27. }
  28. else {
  29. $next = "0";
  30. }
  31. echo "<span style=\"font-size: 16px\"><strong>Strona:</strong></span><br /><div style=\"line-height: 16px;padding-top: 5px\"><a href=\"aukcje?id=".$back."\"><img src=\"images/arrow-left.png\" style=\"padding-right:3px\" /></a> <span style=\"font-size: 16px\"><a href=\"aukcje?id=0\"> 0 </a>";
  32. for($i = 1; $i < $ile_stron; $i++)
  33. {
  34. echo '<a href="aukcje?id='.$i.'"> '.$i.' </a>';
  35. }
  36. echo " <a href=\"aukcje?id=".$next."\"><img src=\"images/arrow-right.png\" style=\"padding-left:3px\" /></a></span></div><br /><br />";
  37.  
  38. for($i=0;$i<$limit ;$i++)
  39. {
  40. echo '<div style="margin-right: 10px;margin-bottom: 10px;display: inline-block;">';
  41. echo '<a target="_blank" href="http://allegro.pl/show_item.php?item='.$items[$i]['itemsList']['itemId'].'"><img src="'.$items[$i]['itemsList']['photosInfo']['photoUrl'].'"/></a>';
  42. echo '<div style="width: 130px;margin-top: 5px;margin-bottom: 8px;line-height: 16px"><span style="line-height:14px;font-size: 11px;font-weight: bold">'.$items[$i]['itemsList']['itemTitle'].'</span><br />';
  43. if ($items[$i]['itemsList']['priceInfo']['priceType'] == "buyNow") {
  44. echo '<span style="line-height:20px;color: red;font-size: 16px;font-weight: bold">'.$items[$i]['itemsList']['priceInfo']['priceValue'].' zł</span></div>';
  45. }
  46. else {
  47. echo '<span style="line-height:20px;color: red;font-size: 16px;font-weight: bold">'.$items[$i]['itemsList']['priceInfo']['priceValue'].' zł</span></div>';
  48. }
  49. echo '</div>';
  50. }



problem w tym że serwer zwraca błąd:
Kod
PHP Notice:  Undefined offset: 0
PHP Notice:  Undefined offset: 1
PHP Notice:  Undefined offset: 2
PHP Notice:  Undefined offset: 3
PHP Notice:  Undefined offset: 4
PHP Notice:  Undefined offset: 5
PHP Notice:  Undefined offset: 6
PHP Notice:  Undefined offset: 7
PHP Notice:  Undefined offset: 8
PHP Notice:  Undefined offset: 9
PHP Notice:  Undefined offset: 10
PHP Notice:  Undefined offset: 11



przypuszczam że mam błąd w kodzie, jednak przejrzałem go już tyle razy i nie mam pojęcia w czym problem, proszę o pomoc

Ten post edytował Aquarius 23.07.2015, 10:24:14
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 20:59