Hello all,
I would like to know what is the best way to query activity streams please?
I use php, wamp and Symfony 5 but in my tests i have so many errors...
and my code looks like this (i removed many parts for the example):
$strava_stream = [];
foreach ($activities as $strava_activity) {
$strava_stream[] = $this->httpClient->request('GET', strava '/api/v3/activities/'. $id . '/streams',
[
'headers' => blabla...
'keys'=> 'latlng,time'
]);
}
foreach ($this->httpClient->stream($strava_stream, 15) as $response => $chunk) {
if ($chunk->isLast()) {
// the full content of $response just completed
var_dump($response->getInfo());
var_dump($response->getContent());}
}
i do a loop to make concurrent requests for each activity (i tried just 4 for now to not overload) and then i get the results in a async way as explained in the Symfony documentation.
Sometimes it works perfectly well and many times i have an error like this:
I tried to play with timeout or catch the exception but nothing is working...
Do you have some explanations? Do i need to add a pause in the script in each loop? Is there another way to queries multiple activities streams in the same time or the files are too big maybe?
I have no idea what is the best way to process several streams and to make something reliable.
THank you very much for your help