curl -X GET \
-H "APCA-API-KEY-ID: {YOUR_API_KEY_ID}" \
-H "APCA-API-SECRET-KEY: {YOUR_API_SECRET_KEY}"\
https://{apiserver_domain}/v2/account
$eachPromise = new EachPromise($promises, [
'concurrency' => 2,
'fulfilled' => function (Response $response) {
if ($response->getStatusCode() == 200) {
$data = json_decode($response->getBody(), true);
// processing response of user here
echo "successes";
}
},
'rejected' => function ($reason) {
echo "fail";
}
]);
is there any way for each promise to execute Cade sends after a few seconds?
For example, at concurrency you have informed 2, so it will send every 2 times, and put a time that after 5 seconds it sends again, similar to a pause at each sending.
$this->client = new Client(['base_uri' => $this->returnBaseUrl()]);
$this->response = $this->client->request($this->method,$this->returnRequestURI(),$this->buildRequest());
Hi dears , i want to call a thousand request in guzzle once time and ensure each callback correct
https://www.bizmate.biz/news/it-articles/multiple-concurrent-guzzle-requests/
require_once "vendor/autoload.php";
use GuzzleHttp\Client;
$client = new Client([
// Base URI is used with relative requests
'base_uri' => 'https://api.ma.io',
// \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
]);
$response = $client->request('POST', '/tok/gen, [
'verify' => false,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded'
],
'json' => [
'username' => 'email@gmail.com',
'password' => 'pass123'
]
]);
i have the error$url
. Is a bug on Guzzle or I'm doing something wrong?$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $string_params,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$client = new Client();
$client->request('POST', $url, [
'form_params' => $array_params
]);