I have an api which pulls a master list of property listings from a real estate association. When I make the request I get back I .txt file of all the results in my request; this is in a XML structure, I am happy with this because all the results I should get are there. However I also wish to download the listings into a MYSQL DB. This is where I am getting issues. The way the api works that you can only request 100 listings at a time. So you have to build a loop that loops the amount of time of than amount of results you got back divided by 100. Then inside that loop have another loop which loops 100 times(the limit)to pull the listings. So when inside my inner loop which is a foreach loop, I am getting issues, or at least I think its there.
The issue is confusing to me cause when I was doing my testing and i echoed $i and $j within the inner loop and everything counted up fine j went from 0 to 1900 as it should so it does go through each result. Just when I try to use those results for say an echo or DB they dont all seem to be there.
Any help would be much appreciated. I ll try to add just the relevant parts of my scripts rather than my whole scripts.
$TimeBackPull = "-9 months";
error_log("-----GETTING ALL ID's-----");
$DBML = "(LastUpdated=" . date('Y-m-d', strtotime($TimeBackPull)) . ")";
$params = array("Limit" => 1, "Format" => "STANDARD-XML", "Count" => 1);
$results = $RETS->SearchQuery("Property", "Property", $DBML, $params);
$totalAvailable = $results["Count"];
error_log("-----".$totalAvailable." Found-----");
if(empty($totalAvailable) || $totalAvailable == 0)
print_r($RETS->GetLastServerResponse(), true);
echo 'total '.$totalAvailable.' <br />';
for($i = 0; $i < ceil($totalAvailable / $RETS_LimitPerQuery); $i++)
{
$startOffset = $i*$RETS_LimitPerQuery;
error_log("-----Get IDs For ".$startOffset." to ".($startOffset + $RETS_LimitPerQuery).". Mem: ".round(memory_get_usage()/(1024*1024), 1)."MB-----");
$params = array("Limit" => $RETS_LimitPerQuery, "Format" => "STANDARD-XML", "Count" => 1, "Offset" => $startOffset);
$results = $RETS->SearchQuery("Property", "Property", $DBML, $params);
foreach($results["Properties"] as $listing)
{
echo $listing["AgentDetails"]["@attributes"]["ID"];
}
}
Another little note is that my ['count'] or in other word the amount of results I get back is what the people i talked to said I should be getting, but the rows inserted or even just echoed never equal up to what It should be