Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Curl problem

Posted on 2008-06-19
3
Medium Priority
?
418 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
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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

783 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