Witam!
Dziwna sytuacja. We wtorek popołudniu przestał działać skrypt, który wyciąga zamówienia z allegro i wrzuca do aplikacji. Skrypt ten był napisany rok temu i działał bez zarzutów.
Okazuje się że po uruchomieniu skryptu dostaje error
  1. php cron_start.php action=allegro sklep=1
  2. rray(2) {
  3. ["text"]=>
  4. string(3675) "object(SoapFault)#113 (9) {
  5. ["message":protected]=>
  6. string(27) "Error Fetching http headers"
  7. ["string":"Exception":private]=>
  8. string(0) ""
  9. ["code":protected]=>
  10. int(0)
  11. ["file":protected]=>
  12. string(69) "../public_html/lib/allegro.php"
  13. ["line":protected]=>
  14. int(4611)
  15. ["trace":"Exception":private]=>
  16. array(4) {
  17. [0]=>
  18. array(4) {
  19. ["function"]=>
  20. string(11) "__doRequest"
  21. ["class"]=>
  22. string(10) "SoapClient"
  23. ["type"]=>
  24. string(2) "->"
  25. ["args"]=>
  26. array(5) {
  27. [0]=>
  28. string(480) "<?xml version="1.0" encoding="UTF-8"?>
  29. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://webapi.allegro.pl/service.php"><SOAP-ENV:Body><ns1:DoGetTransactionsIDsRequest><ns1:sessionHandle>9fe5a8e8c4d83fccc6dba7a1c6a56fca8d65f211846f2f//03_1</ns1:sessionHandle><ns1:itemsIdArray><ns1:item>6654534481</ns1:item></ns1:itemsIdArray><ns1:userRole>seller</ns1:userRole></ns1:DoGetTransactionsIDsRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
  30. "
  31. [1]=>
  32. string(37) "https://webapi.allegro.pl/service.php"
  33. [2]=>
  34. string(21) "#doGetTransactionsIDs"
  35. [3]=>
  36. int(1)
  37. [4]=>
  38. int(0)
  39. }
  40. }
  41. [1]=>
  42. array(6) {
  43. ["file"]=>
  44. string(69) ".../public_html/lib/allegro.php"
  45. ["line"]=>
  46. int(4611)
  47. ["function"]=>
  48. string(10) "__soapCall"
  49. ["class"]=>
  50. string(10) "SoapClient"
  51. ["type"]=>
  52. string(2) "->"
  53. ["args"]=>
  54. array(3) {
  55. [0]=>
  56. string(20) "doGetTransactionsIDs"
  57. [1]=>
  58. array(1) {
  59. [0]=>
  60. object(DoGetTransactionsIDsRequest)#112 (4) {
  61. ["sessionHandle"]=>
  62. string(52) "9fe5a8e8c4d83fccc6dba7a1c6a56fca8d65f211846f2f//03_1"
  63. ["itemsIdArray"]=>
  64. array(1) {
  65. [0]=>
  66. string(10) "6654534481"
  67. }
  68. ["userRole"]=>
  69. string(6) "seller"
  70. ["shipmentIdArray"]=>
  71. NULL
  72. }
  73. }
  74. [2]=>
  75. array(2) {
  76. ["uri"]=>
  77. string(37) "https://webapi.allegro.pl/service.php"
  78. ["soapaction"]=>
  79. string(0) ""
  80. }
  81. }
  82. }
  83. [2]=>
  84. array(6) {
  85. ["file"]=>
  86. string(74) "../public_html/cron_allegro_get.php"
  87. ["line"]=>
  88. int(191)
  89. ["function"]=>
  90. string(20) "doGetTransactionsIDs"
  91. ["class"]=>
  92. string(7) "allegro"
  93. ["type"]=>
  94. string(2) "->"
  95. ["args"]=>
  96. array(1) {
  97. [0]=>
  98. object(DoGetTransactionsIDsRequest)#112 (4) {
  99. ["sessionHandle"]=>
  100. string(52) "9fe5a8e8c4d83fccc6dba7a1c6a56fca8d65f211846f2f//03_1"
  101. ["itemsIdArray"]=>
  102. array(1) {
  103. [0]=>
  104. string(10) "6654534481"
  105. }
  106. ["userRole"]=>
  107. string(6) "seller"
  108. ["shipmentIdArray"]=>
  109. NULL
  110. }
  111. }
  112. }
  113. [3]=>
  114. array(4) {
  115. ["file"]=>
  116. string(74) "../public_html/cron_allegro_get.php"
  117. ["line"]=>
  118. int(503)
  119. ["function"]=>
  120. string(10) "getAllegro"
  121. ["args"]=>
  122. array(4) {
  123. [0]=>
  124. &int(1)
  125. [1]=>
  126. &string(8) "*****"
  127. [2]=>
  128. &string(8) "*****"
  129. [3]=>
  130. &string(8) "*****"
  131. }
  132. }
  133. }
  134. ["previous":"Exception":private]=>
  135. NULL
  136. ["faultstring"]=>
  137. string(27) "Error Fetching http headers"
  138. ["faultcode"]=>
  139. string(4) "HTTP"
  140. }
  141. "
  142. ["code"]=>
  143. int(200)
  144. }


Szukając w internecie znalazłem że może to powodować timeout więc zwiększyłem czas default_socket_timeout z 60 na 600 ale to nie pomogło.

A tutaj część funkcji która pobiera dane

  1. function getAllegro($sklep,$login,$haslo,$api)
  2. {
  3. try
  4. {
  5. $allegro = new Allegro(ALLEGRO_WSDL);
  6.  
  7. $DoQuerySysStatusRequest = new DoQuerySysStatusRequest();
  8. $DoQuerySysStatusRequest->sysvar = 3;
  9. $DoQuerySysStatusRequest->countryId = 1;
  10. $DoQuerySysStatusRequest->webapiKey = $api;
  11.  
  12.  
  13. $DoLoginRequest = new DoLoginRequest();
  14. $DoLoginRequest->userLogin = $login; // string
  15. $DoLoginRequest->userPassword = $haslo; // string
  16. $DoLoginRequest->countryCode = 1; // int
  17. $DoLoginRequest->webapiKey = $api; // string
  18. $DoLoginRequest->localVersion = $allegro->doQuerySysStatus($DoQuerySysStatusRequest)->verKey; // long
  19.  
  20. $key = $allegro->doLogin($DoLoginRequest)->sessionHandlePart;
  21.  
  22.  
  23.  
  24. $doMyAccountItemsCount = new DoMyAccountItemsCountRequest();
  25. $doMyAccountItemsCount->sessionHandle = $key;
  26. $doMyAccountItemsCount->accountType = 'sold';
  27. $count = $allegro->doMyAccountItemsCount($doMyAccountItemsCount)->myaccountItemsCount;
  28.  
  29.  
  30.  
  31. $wysylki =array();
  32. $doGetShipmentDataRequest = new DoGetShipmentDataRequest();
  33. $doGetShipmentDataRequest->countryId = 1;
  34. $doGetShipmentDataRequest->webapiKey = $api;
  35.  
  36. $doGetShipmentDataRequest = $allegro->doGetShipmentData($doGetShipmentDataRequest);
  37.  
  38.  
  39. foreach($doGetShipmentDataRequest->shipmentDataList->item as $w)
  40. {
  41.  
  42. $wysylki[$w->shipmentId] = iconv('utf-8','iso-8859-2',$w->shipmentName);
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50. $doMyAccount2 = new DoMyAccount2Request();
  51. $doMyAccount2->sessionHandle = $key;
  52. /*
  53. Wybrany typ zakładki Mojego Allegro (bid - oferty z zakładki Licytuję
  54. * won - oferty z zakładki Kupione
  55. * not_won - oferty z zakładki Niekupione
  56. * watch - oferty z zakładki Obserwowane: Trwające
  57. * watch_cl - oferty z zakładki Obserwowane: Zakończone,
  58. * sell - oferty z zakładki Sprzedaję,
  59. * sold - oferty z zakładki Sprzedane,
  60. * not_sold - aoferty z zakładki Niesprzedane,
  61. * future - oferty z zakładki Do wystawienia).
  62. */
  63. $off = 0;
  64. $doMyAccount2->accountType = 'sold';
  65. $doMyAccount2->limit = 25;
  66. $itemy = array();
  67. $itemy_dane = array();
  68.  
  69. while($count > 0)
  70. {
  71. $doMyAccount2->offset = $off;
  72. $acc = $allegro->doMyAccount2($doMyAccount2);
  73.  
  74.  
  75.  
  76.  
  77. foreach($acc->myaccountList->item as $it)
  78. {
  79. if(isset($it->myAccountArray))
  80. {
  81.  
  82. $itemy[] = $it->myAccountArray->item[0] . '';
  83. }
  84. elseif(isset($it->item[0]))
  85. {
  86. $itemy[] = $it->item[0] . '';
  87. }
  88.  
  89. /*$itemy_dane[$it->myAccountArray->item[0] . ''] = array(
  90. 'nazwa' => iconv('utf-8','iso-8859-2',$it->myAccountArray->item[9] . ''),
  91. 'cena' => round((float)$it->myAccountArray->item[4], 2),
  92. //'ilosc' => ((int)$it->myAccountArray->item[10]),
  93. );*/
  94. }
  95. unset($acc);
  96.  
  97. $off+=25;
  98. $count-=25;
  99. }
  100.  
  101.  
  102.  
  103. $doGetPostBuyData = new DoGetPostBuyDataRequest();
  104. $doGetPostBuyData->sessionHandle = $key;
  105.  
  106. $doGetTransactionsIDs = new DoGetTransactionsIDsRequest();
  107. $doGetTransactionsIDs->sessionHandle = $key;
  108. $doGetTransactionsIDs->userRole = 'seller';
  109.  
  110. $trans = array();
  111. ...

Znajomy programista patrząc na to sugerował aby zmienić
  1. $off = 0;

na
  1. $off = 3000;


offset od którego API ma pobierać zamówienia w sumie jest ich ok 3500
Po tej zmianie skrypt ruszył. Ale pobiera dane wybiórczo. Nowych zamówień jest ok 200 nie pobranych. Mam na przykład ostatnie zamówienie a z kilku godzin wcześniej brakuje.