Jump to content

php curl


hisoka

Recommended Posts

Those aren't functions, those are constants that are options for cURL. You can see the list here:http://php.net/manual/en/function.curl-setopt.phpNote that cURL is not restricted to PHP. I don't see a specific setting for a timeout while sending data, the timeout and timeout_ms options are used for setting a timeout for all cURL functions, so that would also affect sending data.

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

Sorry I did not understand what do you mean by this :

 

I don't see a specific setting for a timeout while sending data, the timeout and timeout_ms options are used for setting a timeout for all cURL functions, so that would also affect sending data.

 

Could you please explain further ?

 

2) by this :

 

Note that cURL is not restricted to PHP

 

 

you mean that cURL can be used with other programming languages like JavaScript and C++ or what do you mean ?

Edited by hisoka
Link to comment
Share on other sites

Sometime the very clear thing is the most imperceptible to a degree that you doubt on your understanding to it . When you wrote :

 

I don't see a specific setting for a timeout while sending data

 

Does it infer that it does not matter how much time it takes for data to be sent to the server and therefore if it takes the data 5 minutes or 10 minutes to be sent to a server than it is OK ?

 

the timeout and timeout_ms options are used for setting a timeout for all cURL functions, so that would also affect sending data

 

.

so that is used for cause-effect . However I did not understand the cause effect relationship in your sentence .

Link to comment
Share on other sites

I am saying that the timeout settings relate to all cURL functions, not specifically sending data. Everything. I did not see a timeout setting which only applies to sending data but doesn't apply to anything else.

Link to comment
Share on other sites

The PHP manual explains that option on this page: http://php.net/curl_setopt

 

CURLOPT_TIMEOUT_MS The maximum number of milliseconds to allow cURL functions to execute. If libcurl is built to use the standard system name resolver, that portion of the connect will still use full-second resolution for timeouts with a minimum timeout allowed of one second.
Link to comment
Share on other sites

OK suppose I have a webpage with a submit form and using cURL , I must do the following :

 

1) multiple 789 with 2

2) put the result in the submit form box

3)click submit to send the result to the server

 

all these three steps should be done in one second . That is I must multiple and return the result to server in one second . Of course , it is impossible to do it manually . However , it is possible to do it using cURL . Is

CURLOPT_TIMEOUT_MS

 

the right predefined constant to do it ? or is there a function or another predefined constant that can do it ? I read all of them but I could not find one that serve the context more than

CURLOPT_TIMEOUT_MS

and

CURLOPT_TIMEOUT
Link to comment
Share on other sites

I don't know what you're trying to explain. I don't know where cURL even fits in to that example. You can have a form with a button to do some math, fill in values on the form, and submit it to the server all in Javascript.

 

Are you trying to do something like set a time limit on how fast someone needs to submit a form on a page, like a timer for a quiz or something?

Link to comment
Share on other sites

Are you trying to do something like set a time limit on how fast someone needs to submit a form on a page

 

 

yes :)

 

and I would like to do it with cURL but I do not know how :(

Edited by hisoka
Link to comment
Share on other sites

That is not what cURL is for. cURL cannot do that.

 

You have to use the right tools for the right job, cURL is not the tool for that job.

Link to comment
Share on other sites

That is not what cURL is for. cURL cannot do that.

 

cURL is used to send data to a server website ; It can be used to submit a form to a server website . So why you think that cURL could not send data to a server website in a specific period of time ??

CURLOPT_TIMEOUT_MS

and

CURLOPT_TIMEOUT

cannot set the period of time that a form is submitted or returned to server ??

Edited by hisoka
Link to comment
Share on other sites

cURL is an interface that allows PHP (or other languages) on the server to send HTTP requests to another server.

 

Form submission is done from the user's computer, not on the server that PHP is running on.

Link to comment
Share on other sites

You cannot submit a form from the user's computer using cURL.

 

What you can do is send data to another form on another website from your server. The user and their browser are not involved in this process.

Link to comment
Share on other sites

I understand very well what you mean and I congratulate you for this wonderful and simple explanation . What if I download cURL and try to submit the form from windows or Linux command prompt ? like for example in these sites :

 

http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request

 

or this :

 

https://davidwalsh.name/curl-post-file

 

or this :

 

http://linux.byexamples.com/archives/311/sending-http-post-using-curl-command/

 

?

 

is it still possible ? and if not why ?

Edited by hisoka
Link to comment
Share on other sites

You send curl requests from the command line on your computer, but it is pointless

 

 

Why you think it is pointless ? is not it possible to submit a form from windows or Linux prompt command in a specific period of time that you specifies using cURL ??

 

 

That's already outside the subject of web development.

 

 

I know it is outside the subject of web development . However , concerning this thread , I do not want to know how to submit a form in a specific period of time using cURL in windows or Linux command prompt . I want only to know if it is possible to set a time limit for the submitted form when using cURL from windows or Linux command prompt and if it is not possible then why ?

Link to comment
Share on other sites

I have no idea what you're asking for at this point. In PHP, cURL is used to send a request from the web server to another server (or even the same server). It's not "submitting a form", you just send a get or post request with the data that the page that handles the form expects. And it happens from server to server, not from user to server.

 

I want only to know if it is possible to set a time limit for the submitted form when using cURL from windows or Linux command prompt and if it is not possible then why ?

I'm going to guess that the answer to that question is "no", and the reason is because you don't understand what cURL is for. It's not for submitting forms, it's for sending requests. If you really do understand what it does then my question is why do you want to use cURL instead of just opening the page in a web browser and submitting that form? I also think you don't understand what the timeout settings are used for. Again, it has nothing to do with submitting a form.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...