Skip to content

Instantly share code, notes, and snippets.

@tolgatasci
Created September 22, 2022 10:37
Show Gist options
  • Save tolgatasci/ef7aaefd5b166a26c8ad07b5be30b168 to your computer and use it in GitHub Desktop.
Save tolgatasci/ef7aaefd5b166a26c8ad07b5be30b168 to your computer and use it in GitHub Desktop.
dynamics_data
$domain = "https://r.operations.dynamics.com";
$callback = json_decode(get_url($domain."/data",$token));
$i = 0;
$limit = 100;
$page = $request->get('page');
if(empty($page)){
$page = 1;
}
$data_call = [];
$total = count($callback->value);
echo "".($page * $limit)." > $total";
if(($page * $limit) - $limit > $total){
return false;
}
foreach($callback->value as $entity){
if($i >($limit * ($page - 1))){
$entity_data = json_decode(get_url($domain."/data/".$entity->url,$token));
if(!empty($entity_data->value)){
if(count($entity_data->value)>0){
file_put_contents("data/".$entity->url.".json",json_encode($entity_data));
}
}
}
if($i>($limit * $page) + $limit){
break;
}
$i++;
}
echo ' <script>
setTimeout(function() {
window.location.href = "test?page='.($page + 1).'";
}, 1000); // 1 second
</script>';
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment