Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Mauro Spivak
    @mspivak
    Hey there! I'm working with a Pool of Requests. When a request is successfully fulfilled, I want to be able to know the URL of the request, so I can (say) print a message, but all I get is a response object and an index
    ctrldotnet
    @ctrldotnet
    Does anyone happen to know of a code example or way where I could run Guzzle as a service, i.e essentially have it check against say Redis for new URLs to fetch? Currently it stops running once all promises are fulfilled in the setup I have. I mainly need it for retrying timeout requests with modified request options (the latter part being the problem), i.e changing proxy or header., so having it daemonized would help in sending requests back into the pool to scrape.
    Roskovynskyi
    @oleksandr-roskovynskyi
    What is the fastest way to send 100,000 HTTP requests to PHP and retrieve data from them? Need to get numerical values from a large list of profiles on the REST API + JWT, aggregation method API system where you need to get data there.
    ctrldotnet
    @ctrldotnet

    @oleksandr-roskovynskyi fastest way isn't by using Guzzle, as great as Guzzle actually is.. If absolute maximum speed efficiency is desired, you're best off using an approach utilizing fsockopen and pcntl_fork or similar. Or simply use curl-multi (which Guzzle does too) directly. There's quite a few different approaches to these things, and I think stackoverflow is the best place to find the niche solutions you might look for. It also depends on whether or not your target server is expecting your multitude of connections.. if so, then you can just go nuts and open up 1000 threads. If not, then do keep in mind that webmasters often optimise their setups based on average traffic and your sudden flood of requests could cause problems for them.

    If you're set on using Guzzle, the Pool/Batch mode is what you're looking for. Keep in mind though that the result set will grow in memory until all results have been returned. If you want async return, look into using iterators and each_limit.. @alexeyshockov has an awesome code example for that here: https://github.com/alexeyshockov/guzzle-dynamic-pool .. It creates the requests sequentially though, so it's not optimised for speed, but it's still fairly fast once it has opened all the threads it's allowed to.

    still-dreaming-1
    @still-dreaming-1
    I'm a bit confused about PSR-7 and why adding guzzle my project is suggesting the following: guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
    The other suggesting about the intl extension at least explained what the impact was, performance. But I'm not sure how Guzzle would be different with or without that other zend thing.
    It got more confusing from there because I looked at their github page, https://github.com/zendframework/zend-httphandlerrunner and it says it has moved to https://github.com/laminas/laminas-httphandlerrunner
    But I don't know if that newer project is compatible with guzzle or not, or if installing either of those would help guzzle in any way.
    phillmac
    @phillmac
    Seems like there was a name change for some reason
    so it should be compatible. as to the benefits i guess there's nothing like a good 'ol benchmark
    still-dreaming-1
    @still-dreaming-1
    I'm still confused though. Are you saying just installing it will cause it to be used by Guzzle, and could potentially affect performance?
    I installed Guzzle 6.5, since that is what got installed by default (since 7 is still beta), and 6.5 is still recommending the old zend library, which makes me even more unsure of if the new one would be compatible with 6.5
    phillmac
    @phillmac
    Fair enough, I wouldn't worry about it, you can read some of the back story here guzzle/psr7#204
    If you don't know what it's for, you prolly don't need it
    still-dreaming-1
    @still-dreaming-1
    Hmm. From that is seems like it doesn't matter at all unless I am making an HTTP server. I'm only using Guzzle as a client to communicate with a server, so I guess I don't need to worry about it.
    phillmac
    @phillmac
    Seems that way to me too
    still-dreaming-1
    @still-dreaming-1
    Cool thanks
    still-dreaming-1
    @still-dreaming-1
    I'm having hard time understanding enough to put a request together for alpaca where it uses my API key for authentication. Here is an example of what I'm wanting to do if it were done with curl from a terminal: 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
    You can see the example better here: https://alpaca.markets/docs/api-documentation/api-v2/
    It's under the authentication heading
    phillmac
    @phillmac
    still-dreaming-1
    @still-dreaming-1
    Hmm, yeah looks like that should do what I want pretty simply. I was looking at the stuff for constructing the client prior to making the request.
    phillmac
    @phillmac
    $client = new GuzzleHttp\Client(['headers' => ['X-Foo' => 'Bar']]);
    If you wanna do it that way rather then per request
    still-dreaming-1
    @still-dreaming-1
    Okay, I guess I was just over complicating it somehow. I will try it
    still-dreaming-1
    @still-dreaming-1
    Hmm. I'm getting an error from Curl. I wonder if I even have curl? I'm on Windows 10. My use case is very abnormal. I'm not running code from a server or for a website, it is just a desktop GUI application running on my computer.. Do you know how I would check if I have curl available to Guzzle?
    Looks like it is enabled in my php
    So I guess I have curl
    still-dreaming-1
    @still-dreaming-1
    It's working! I had to download CA certificates, and set the path of the file on my php.ini for the curl settings. My code is downloading stuff from the Alpaca API now!
    rpicheta
    @rpicheta
    Hi all! Is there any way to set base_uri in different way than pass it thru constructor?
    DiegoFSFlor
    @DiegoFSFlor

    $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.

    Quiec
    @Quiec
    Hi I have a problem
    GuzzleHTTP converting url to capital letters
    Quiec
    @Quiec
    CURLE_URL_MALFORMAT
    Edgar Ibrahimov
    @eibrahimov
    Hi all,
    I use Guzzle to authentication https://auth.prestashop.com/login with method POST and params email, password, and SubmitLogin.
    Before POST request I need also add to here hidden _token params getting from the first request by the GET method to this link. How I can do it with the best practice? Thank you
    Arne Groskurth
    @arnegroskurth
    Does anyone know if I can extract the complete HTTP message that is actually send over the wire for both PSR7 request- and response-objects?
    Without writing that myself...
    Arne Groskurth
    @arnegroskurth
    FYI: \GuzzleHttp\MessageFormatter
    Mario Bonito
    @elite6adger
    Hi everyone, just have some issues with concurrency and Digest Authorization. Using Guzzle 6 anyone been successful with that? When I do it one at a time I have no issues, but when I set up a Pool and try concurrent all the request promises fail with 401. I am passing all the credentials correctly and setting the 'auth' in the request. Thoughts?
    Alexander Tarkhov
    @tarkhov
    Hi guys, I present the second release of the Guzzle XML PHP library for sending XML requests. https://github.com/tarkhov/guzzle-xml/releases/tag/v0.1.1
    hershkoy
    @hershkoy

    Is it possible to run Guzzle as a standalone, without laravel? I am getting this error:

    GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host

    I can ping the host from the server. curl to same address also works. Any way to fix this?

    Carine93
    @Carine933_twitter

    what is this? example:

    composer upgrade guzzlehttp/guzzle
    Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.

    composer remove guzzle/guzzle
    guzzle/guzzle is not required in your composer.json and has not been removed

    phillmac
    @phillmac
    @Carine933_twitter The guzzle package got renamed. You should use the new name iff possible
    Carine93
    @Carine933_twitter
    But what should I do? I can't remove guzzle/guzzle. "guzzle/guzzle is not required in your composer.json and has not been removed" and "Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead."
    I have ofcourse VPS, 755, user/group=www-data/www-data
    phillmac
    @phillmac
    @Carine933_twitter If you're just typing to install something and everything is working then there is no problem and you can safely ignore the warning. If you are a developer and you use guzzle as a dependency then you should look at updating the dependency
    Cutye
    @SrGutyerrez_twitter
    Hello, why guzzle doesn't execute curl requests in localhost? That's make an infinite request
    Zachary Smith
    @zachisit
    Hi all. When I send a POST request with Guzzle, it returns the response but as an HTML and not json if the response returns an error. For successful responses it is a json response. Am I doing something wrong?