• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

Compatibility of CURL question

I'm writing a script which needs to communicate with a remote site to perform some functions. I need to know the best way to handle this so that the script will be compatible with as many webhosts as possible. I'm looking for some advice on the compatibility of CURL. I beleive some hosts have either disabled this feature, or have not installed it. I know there are other methods I can use, but I'm not sure about their compatibility either. Can anyone offer up some suggestions for me?

0
savetheorcas
Asked:
savetheorcas
  • 4
  • 4
  • 3
1 Solution
 
andy_thedestroyerCommented:
Well if the libcurl package is compiled with php then CURL can fetch pages from just about any server, HTTP, GOPHER, USENET, FTP etc.

or did you mean that your script is going to run on different servers. Is it fetching pages from multiple servers or is it going to be run from multiple servers.

You can check you intallation by creating a php page with nothing but
<?
phpinfo();
?>

This will desplay all the features that are available with you installalation and if you scroll down to the section under the header CURL it will either say enabled or disabled.

What might be easier and is enabled on all instillations is just using

$handle = fopen("URL",'r')

Just read the page into a buffer as you would any text file. This totally works. I've done it. Easier to use than curl too but if you need to do more than just read in a web page.. you may have to use curl.


-a
0
 
savetheorcasAuthor Commented:
My server isn't the problem, the script will be used by others on their server and want to make sure that they are able to use all features of the script which require communication with my remote site. I'm just trying figure out what method would be the most compatible.

Sean
0
 
andy_thedestroyerCommented:
What are they doing with the remote site. If they just need to access a page then:

fopen()

will do the trick. If your users need to send data to your server you can use

fsockopen or curl

with fsockopen you can do things like send POST variables thich your script can read in with $_POST[]. You can fake a form submission.

fsockopen is more compatible than curl. Some ISPs may not compile libcurl due to security reasons however it is pretty standard now.

If you give me an example of a task might be able to help more.

-a
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
savetheorcasAuthor Commented:
The main task is the script connecting to my server to do two things:

1) Search for files available for download
2) Check for script updates.

Is fsockopen fairly standard with all hosts?

Thanks
0
 
andy_thedestroyerCommented:
Yes fsock is standard with most hosts. Again this is something that an administrator could choose to disable at compile time like CURL but it is default enabled.

It sounds like fsockopen and other socket fucntions could be the way to go for you. However if you have trouble with this.

For simplicity
Just pass variables into the URL and use fopen ex.

// user version
$myver = 4;

$filename = "http://www.myhost.com/updater.php?v=" . $myver;
$handle = fopen($filename,'r');

have your script return 1if there is a newer version or 0 if there isn't.

you can have another script return a list of files available for download.

To get the file there are a variety of different functions, but the easiest would be the ftp functions like
ftp_connect and ftp_get

If you are new to networking I suggest sticking with fopen and expanding if needed when you get that working.
0
 
savetheorcasAuthor Commented:
I'd prefer using something other than fopen(), CURL or fsockopen would be fine. I know that my host has disables remote fopen, so I'm going to assume other hosts have done this as well.

On average, which would you say is enables on the majority of hosts, CURL or fsock?
0
 
flashtCommented:
Maybe just  try file() :) If the script on your server would handle get method in ling ($var=_REQUEST[NAME]; -> http://myserver.com/index.php?NAME=My%20Name), then file will handle it:

$mysite = file(http://myserver.com/index.php?NAME=My%20Name);

Thats the best way and it will work in 100% of servers.

0
 
flashtCommented:
*"in ling"  - dunno what was that - it should be in URL
0
 
andy_thedestroyerCommented:
I think any ISP that would enable or disable CURL would also do the same with fsockopen. I would use fsockopen because I feel it is easier to use and understand.

You could also write the script to use both, one if the other doesn't work. Create a Connect class in which you determin what is available use that. Then include that in your script and connect through the Connect class methods. This way you can connect in different ways and you script doesn't care.



0
 
savetheorcasAuthor Commented:
Andy, can you explain this a bit more? Are you talkking about doing something checking if cUrl, etc is installed enabled on the server then calling the right function?

I'm not even sure how much concern I should have as for all I know cURL might be enabled on most hosts.
0
 
flashtCommented:
If you want to check if CURL is installed, use function_exists().

For example:
if (function_exists('curl_setopt')) { echo 'like wow! curl is installed!'; } else { echo 'och s-h-i-t... no curl ;-('; }
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now