Page 1 of 1
Built-in HTTP request php functions.
Posted: Wed Jul 23, 2008 4:47 pm
by JellyFish
Are there built-in php functions that allow me to make post and get HTTP requests? All the functions I've found are extensions why wouldn't php have some of these basic functions built-in?
Are my only options extensions?
Re: Built-in HTTP request php functions.
Posted: Wed Jul 23, 2008 4:56 pm
by Apollo
With
file_get_contents("http://some.random.url/whatever?param=bla") you can get the contents of a remote page, which invokes a normal GET request.
Similarly,
file will get the data as an array, and
readfile will output the downloaded content directly to your script's own output.
Unfortunately, there is not an easy alternative to do POST requests. You'll have to mess around with
fsockopen, or use or something like
cURL (the latter is actually quite nice to work with, and also takes care of secure https connections).