Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - multiple requests with curl (NOT 'multi-threaded')

If i want to do multiple things (that require cookies) with curl, for example:

  1. login to (my own) blog
  2. then automatically submit a blog post

do I do this in one curl instance before curl close or do i close first session and then start second one for second task? (Sorry if it's dumb question but i can't quite get it. Generally all examples on the net i find about curl are doing only one thing... this doesn't help me with understanding it.)

like image 805
Phil Avatar asked Aug 14 '09 00:08

Phil


1 Answers

Generally speaking:

  1. Initialize curl. (curl_init, or curl_multi_init)
  2. Do thing(s). (in multiple curl_exec calls if needed, or curl_multi_exec)
  3. Close curl. (curl_close or curl_multi_close)

So yes, all in one session.

like image 51
karim79 Avatar answered Nov 04 '22 12:11

karim79