Giter Club home page Giter Club logo

Comments (5)

zachborboa avatar zachborboa commented on May 21, 2024

Thank you for the issue. Can you provide an example use case?

from php-curl-class.

hackel avatar hackel commented on May 21, 2024

Anything in which you are performing multiple requests to the same URL. E.g.:

$curl->setUrl('http://somegreat/api');
$curl->post(array('name'=>'foo');
$curl->get(array('q'=>'keyword'));
$curl->patch(array('id'=>100, 'name'=>'bar');

It's not a requirement, I can certainly include the URL in every request (which I am doing now), it just seems like it might be a natural/elegant method to add. Even what I wrote above seems too procedural. Possibly chaining them like this might be better:

Curl::url('http://somegreat/api')
    ->setOpt(CURLOPT_AUTOREFERER, true)
    ->setCookie(...)
    ->get(...);

from php-curl-class.

zborboa-g avatar zborboa-g commented on May 21, 2024

Here is how this could be implemented

$curl = new Curl();
$curl->setUrl('https://api.example.com/inbox/');

// OR

$curl = new Curl('https://api.example.com/inbox/');

And the usage:

for ($i = 1; $i <= 10; $i++) {
    $curl->get(array(
        'page' => $i,
    ));
}

However, there would be a bit of ambiguity. For example, $curl->get() currently expects a url string or an array of urls as the first parameter. Using $curl->setUrl() and then calling $curl->get() with an array of data would be ambiguous as we would not know if the array passed is a set of urls or data.

from php-curl-class.

hackel avatar hackel commented on May 21, 2024

Yes, I don't see an obvious way to maintain backward compatibility... You could possibly move the parallel processing into it's own get_parallel function or something, and then check if $url is an array in every function, and if so use it as $data. This might be too big a change, though.

from php-curl-class.

zborboa-g avatar zborboa-g commented on May 21, 2024

Actually I believe there is a way this could work by using Curl::is_array_assoc() on the first parameter. A user is going to do parallel requests using get() with an indexed array and not with an associated array.

from php-curl-class.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.