call API many times but eventually run into error, PHP

levittlevitt Member Posts: 13
Hi, 

I have trouble on multiple calls on api, due to my company policy I can only show my problem as following example 

I have an array contains all my products, which is around 500

then for each of item in this array 

execute: $product=$api->products->get($the_product_id);

the type of $the_product_id is integer, 

when I run the PHP application, first time only shows part of result, after I refresh the page, the application crashed. 

I assume this have something to do with api calls time out, but I am not sure. 

Please help me with some idea that allows me call api functions hundreds times, 

Thank you very much!

4 comments

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 654 moderator
    @levitt it sounds like there is a problem with your application. The Item endpoint is faithfully returning you an array of results but you’re not able to execute a function to filter through it effectively as your app crashes, am I right?

    Adrian Samuel

    Software Developer

    Lightspeed HQ

  • levittlevitt Member Posts: 13
    @levitt it sounds like there is a problem with your application. The Item endpoint is faithfully returning you an array of results but you’re not able to execute a function to filter through it effectively as your app crashes, am I right?
    hi, yes. 
    the functions I made can execute without error, and there is a loop inside of function, once I add this line in the loop " $product=$api->products->get($the_product_id);", (the loop is normally 500 times in my project.) the function is not working anymore, and the only error message I have is 500... 

    so I am struggling to find out what's is the reason of this error 
  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 654 moderator
    @levitt, along with the error, you should have received some information in the response body. Could you tell me what that is please

    Adrian Samuel

    Software Developer

    Lightspeed HQ

Sign In or Register to comment.