0

i need to do a "file_get_contents" on a URL and there has to be data posted to the url before the contents are retrieved. is this possible? maybe something like

$contents = file_get_contents($_POST"http://www.example.com/");

so that i can then work with the $contents variable?

cwal
  • 3,732
  • 3
  • 19
  • 20
  • Try [this link: How to post data in PHP using file_get_contents?](http://stackoverflow.com/questions/2445276/how-to-post-data-in-php-using-file-get-contents) and see if you can find something usable. – Wh1T3h4Ck5 Apr 17 '11 at 23:11
  • yes thank you, of course i found this link immediately after i asked my question XD – cwal Apr 17 '11 at 23:26

2 Answers2

0

You cannot*** POST data using file_get_contents, you must use something like cURL

* I mark this because it is actually possible taking advantage of the third parameter which uses http context(see example one). However it really isn't worth your trouble if you have something like cURL.

Mike Lewis
  • 63,433
  • 20
  • 141
  • 111
  • I agree. Additionally, you shouldn't rely on `file_get_contents` to get URL data either. – Christian Apr 17 '11 at 23:10
  • the http context method seems to have done the trick, i realise i should be using cURL, i know its much stronger, but alas, im just looking for a quick fix and it seems the context trick has done the job. same with file_get_contents, i simply need it to extract 1 link, so it does the job. – cwal Apr 17 '11 at 23:28
0

Ah, I have tried to do this. Simply put you can't unless you install new extra software on your sever and go through A LOT of hassel and server load.

Best bet is to use GET if at all possible!

:)

hozza
  • 619
  • 2
  • 12
  • 27