Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:23:09+00:00 2026-06-10T11:23:09+00:00

There has to be a better way! This is my code: checksession(); $restNew2 =

  • 0

There has to be a better way! This is my code:

checksession();
$restNew2 = new RESTConnector();


$urlNew2 = "https://localhost:9630/api/products/";
$restNew2->createRequest($urlNew2,"GET", null, $_SESSION['cookies'][0]);
$restNew2->sendRequest();


$responseNew2 = $restNew2->getResponse();
$xmlNew2 = new SimpleXMLElement($responseNew2);

foreach ($xmlNew2 as $purge){
    $id = (string)$purge->attributes()->id;

checksession();
$restNew = new RESTConnector();


$urlNew = "https://localhost:9630/api/products/".$id."/";
$restNew->createRequest($urlNew2,"GET", null, $_SESSION['cookies'][0]);
$restNew->sendRequest();


$responseNew = $restNew->getResponse();
$xmlNew[] = new SimpleXMLElement($responseNew);



}
$array = array();

foreach ($xmlNew as $purgeDet){
    $code[] = (string)$purgeDet->code;
    $classId[] = (string)$purgeDet->class['id'];
    for($i=0, $count = count($xmlNew); $i < $count; $i++) {
$array[$code[$i]]['classId'] = $classId[$i];
    }
}
print_r($array);

The first response gives me about 300,000 lines back so then I have to parse through that to grab the id of a product in order to send another request to get a full render of the product. It ends up sending like 40,000 requests. My hopes is to insert this into a mySQL database at night using cron so I can create reports on it the next day. Any ideas? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:23:11+00:00Added an answer on June 10, 2026 at 11:23 am

    Id do it in chunks. Make the first API call and loop over it building a list of just ID’s and store it. Id store them in a file with 1 per line… then you can the file line by line later instead of loading the whole array into buffer OR you coudl still read the file to an array… whichever ends up being the better solution.

    Then read the file and loop through the IDs making your detail calls and storing them.

    UPDATE:

    You could also keep the grabbing of the IDs on the compiled side by using an xpath query.

    $xmlNew2->xpath("//THE_ELEMENT_WITH_THE_ID/@id");
    

    But i dunno if this is going to save you much because youd still need to loop over this… it just saves you have to call SimpleXMLElement::attributes on each node. But the result is still going to be array of attribute elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There has to be a better way to do this. I just want to
There has to be a better way of writing the js in my function....
Is there a better way to do this: perms = product(range(1,7),range(1,7),range(1,7)) so that I
There has got to be a more efficient way to do this in Ruby.
I have this code here and it works but there has to be a
Is there a way to make this code work without a Warning? function myFunction($value,
Is there any JavaScript/jQuery library for creating step-by-step forms? It's better if it has
There has GOT to be a simple way to programmatically render HTML into a
I know there has to be a way: I need help getting any hot
Consider: [self.navigationController popToViewController:[[self.navigationController viewControllers]objectAtIndex:1] animated:YES]; Is there a better way to get index of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.