Jump to content

CURL help - is it really so tricky?


b.prisera

Recommended Posts

Hello,

 

I have a very stupid question I guess  Wink I built my own website a year ago, when I started with PHP. It works quite fine but, as I don't improve my PHP skills, I don't keep my knowledge up-to-date. It happened to me a few weeks ago that my Guestbook ('outsourced' by a free guestbook provider) stopped viewing. It took me a really long time to find out why, but after loads of questions I found out that my webhosting provider doesn't support the url_fopen function any more whilst my 'outsorcer' recommends it. The hosting provider only wrote me, 'we don't allow this any more, use curl function instead'.

 

Please, I'm sure it's really easy, but I've been searching the websites in my language (Czech) and haven't found any curl tutorial place to learn from until I found your website. Please, could someone help me to convert this code to a curl code they require? I would be very very grateful! Cheers :-)

 

This is the code that the 'free-guestbook-services' website recommends to be included in the source code. I need to replace this with curl:

 

if (ereg("msie", strtolower($_SERVER['HTTP_USER_AGENT'])) AND !ereg("opera", strtolower($_SERVER['HTTP_USER_AGENT']))){

$ie=1;

}

include("http://vsevjednom.cz/guestbook.php?gb=1248&odpoved=".$_GET['odpoved']."&gb_pg="

.$_GET['gb_pg']."&hledat=".$_GET['hledat']."&ie=".$ie);}

 

Thanks, thanks, thanks!!! :-)

Lucie  ;)

 

(http://www.nikk.cz)

Link to comment
Share on other sites

Here is a curl function to fetch a url:

 

function fetch_url($url) {
  $ch = curl_init($url);

  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  $content = curl_exec($ch);
  return $content;
}

 

You should probably use it like this:

 

echo fetch_url("http://vsevjednom.cz/guestbook.php?gb=1248&odpoved=".$_GET['odpoved']."&gb_pg="
.$_GET['gb_pg']."&hledat=".$_GET['hledat']."&ie=".$ie);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.