Thanks
Getting info inscript
Moderator: General Moderators
-
sabastious
- Forum Newbie
- Posts: 8
- Joined: Thu Jul 20, 2006 6:09 pm
Getting info inscript
How in php do you give a url in a script and get a response back IN the script that you can then set to a variable? if that makes sense 
Thanks
Thanks
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
file_get_contents(), cURL maybe?
-
sabastious
- Forum Newbie
- Posts: 8
- Joined: Thu Jul 20, 2006 6:09 pm
It's for a Query String
I dont have the code with me, but I did it in VBScript/ASP a while back. I ran a line of code that called a file somewhere out in the web. This file then ruturned a string of data only. I could take this data and place it into a variable, and parse it ect etc.
I used it when I was building a script to check whether a credit card was valid and whether the tranaction could be processed. I sent out the HTTP Request(I think thats what its called) and it sends back the response, and I never actually leave the script.
Can this be done in PHP?
I used it when I was building a script to check whether a credit card was valid and whether the tranaction could be processed. I sent out the HTTP Request(I think thats what its called) and it sends back the response, and I never actually leave the script.
Can this be done in PHP?
-
sabastious
- Forum Newbie
- Posts: 8
- Joined: Thu Jul 20, 2006 6:09 pm
Sorry i'm new to PHPThe Ninja Space Goat wrote:cURL can do that...
What would be the syntax to grab the string sent back from https://theurl.com/thefile.com?thevar=value ?
Using cURL of course.
I've been reading the docs, but they are not making a lot of sense to me
IIRC:
Code: Select all
$cx = curl_init("https://theurl.com/thefile.com?thevar=value");
curl_setopt($cx, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($cx);
curl_close($cx);or just:
Code: Select all
$response = file_get_contents("https://theurl.com/thefile.com?thevar=value");