-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add setUrl() method #82
Comments
Thank you for the issue. Can you provide an example use case? |
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(...); |
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, |
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. |
Actually I believe there is a way this could work by using |
Typically when working with APIs, all requests are sent to the same URL. It doesn't make sense to specify this over and over again. There should be a single call to set the URL to use for every request.
The text was updated successfully, but these errors were encountered: