0

Is it possible for PHP to log into websites and interact with them?

If so, what technologies do I need to start looking into?

Basically, what I need to do is fill out forms using PHP. I suppose cURL could do this, but I'm not entirely sure.

Chris R.
  • 699
  • 8
  • 23
  • Yes, it can. You'll need HTTP. Beyond that, good luck. – Marc B Jan 12 '12 at 21:38
  • Too broad and needs more info. Is it always going to be the same forms? If so, you won't need to do any html parsing, just send the requests. To log in you would have to use curl to send login request, grab the returned session id cookie and add this to following requests... – dqhendricks Jan 12 '12 at 21:43

2 Answers2

3

You'll need curl: http://php.net/manual/en/book.curl.php

Vladimir
  • 818
  • 5
  • 13
3

Your question is very broad, but basically:

  1. Use cURL to get the HTML of a page.
  2. Parse the HTML and find form elements (see this answer on HTML parsing).
  3. Generate data to submit based on the inputs in the form.
  4. Use cURL to create a request to the submit attribute of the form (making sure to use the specified method).
Community
  • 1
  • 1
Alex Coplan
  • 13,211
  • 19
  • 77
  • 138