Skor Posted January 10, 2008 Share Posted January 10, 2008 I'm trying to help a client out here. This is typically out of my domain, but the forum's been great in the past. Here's what we're trying to do, but don't know how to in PHP. 1. I have a URL string where the client needs to include some variable information. test.abc.com:8080?variable1=9899&variable2=09oid&variable3=Y 2. What comes back is either a YES or a NO 3. The code will branch accordingly. My question is what is the best approach to connect to the site? I've done a little research and found a couple of alternatives -- fsockopen, fopen, GET/HTTP. The partner can't get what he's coded and wanted to know if he's just barking up the wrong tree. Just looking for a recommended approach here. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
nikefido Posted January 10, 2008 Share Posted January 10, 2008 can't ftp? think the permissions would be set to where connecting to the site with fopen etc wouldn't do you much good. don't quote me on that, however. Quote Link to comment Share on other sites More sharing options...
Skor Posted January 10, 2008 Author Share Posted January 10, 2008 It's not ftp, I'm requesting info from one of their online databases with a request. fopen seemed odd to me too. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 10, 2008 Share Posted January 10, 2008 You can also use cURL Ken Quote Link to comment Share on other sites More sharing options...
priti Posted January 10, 2008 Share Posted January 10, 2008 Hi, I have done these kind of functionality where i have to call a url with arguments and i will get the response accordingly .I have used fsockopen() in these secnarios many a times. But yes you can also explore CURL lib also.i think both are good . Regards Quote Link to comment Share on other sites More sharing options...
dsaba Posted January 10, 2008 Share Posted January 10, 2008 $url = 'test.abc.com:8080?variable1=9899&variable2=09oid&variable3=Y'; //send certain variables $output = file_get_contents($url); //request the page through HTTP GET echo $output; //get your YES or NO file_get_contents() is optimized to be better/faster than fopen() in simple cases like HTTP GET Read the manual. URL Wrappers must be ON to access remote urls Quote Link to comment Share on other sites More sharing options...
Skor Posted January 10, 2008 Author Share Posted January 10, 2008 Thanks for the ideas. I appreciate it. Quote Link to comment Share on other sites More sharing options...
priti Posted January 10, 2008 Share Posted January 10, 2008 Kindly make a note to check allow_url_fopen in php.ini file_get_contents depend on that setting.If it is off you won't be able to access it. regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.