Solved

Curl problem

Posted on 2008-06-19
3
406 Views
Last Modified: 2008-06-19
Hi,
I am using the following code

        $ch = curl_init("http://www.mortgages.ie/rates_new.cfm");
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);      
        curl_close($ch);
        echo $output;

the output i get is 1, i dont get the whole page displayed?
0
Comment
Question by:markmchugh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:kszurek
ID: 21821347
Mayby:
echo file_get_contents('http://www.mortgages.ie/rates_new.cfm');

Open in new window

0
 
LVL 19

Expert Comment

by:bevhost
ID: 21821372
why is the CURLOPT_POST there?
there isn't any data to POST.
Should be a GET.
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21821405
The code is working, but the URL you quers does not return anything or has a protection against script usage.

If you use:
$ch = curl_init("http://www.example.com/");
$ch = curl_init("http://www.mortgages.ie/mortgages/rates.cfm");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.8.1.14) Gecko/20080410 SUSE/2.0.0.14-2.3 Firefox/2.0.0.14');
$output = curl_exec($ch);
curl_close($ch);
echo $output;


it works
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question