Comments (5)
Thank you for the issue. Can you provide an example use case?
from php-curl-class.
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.
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.
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.
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)
- High memory consumption and fetching random proxy from list problem HOT 4
- Proxy web help HOT 1
- Avoid Error: SSL peer certificate or SSH remote key was not OK (CURLE_SSL_PEER_CERTIFICATE): SSL certificate problem: self signed certificate in certificate chain HOT 3
- multi_curl ,’setCookieString‘ cannot be used HOT 1
- Content-Encoding: gzip issue HOT 1
- Warning gzdecode(): data error after update to 9.12.01 HOT 3
- Base class for Curl and MultiCurl HOT 1
- Deprecated: Creation of dynamic property Curl\Curl::$rfc6265 is deprecated HOT 2
- CurlStringFile: Object of class CURLStringFile could not be converted to string HOT 1
- Having issues with post json or array HOT 1
- Update ci to work with PHPUnit 10 HOT 1
- Fix recently failing CI HOT 1
- Return types HOT 3
- Unsupported protocol (CURLE_UNSUPPORTED_PROTOCOL): Protocol "ftp" not supported or disabled in libcurl HOT 3
- 302 Moved Temporarily HOT 1
- Curl->diagnose(), uncaught type error if Content-Type is null, PHP 8.1.13 HOT 3
- How to get the list of URLs that have not been executed yet when I use MultiCurl::stop() HOT 3
- Retry manually HOT 3
- issue with response content being double decoded HOT 5
- Detected an illegal character in input string in /var/www/site/vendor/symfony/polyfill-mbstring/Mbstring.php:536 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-curl-class.