using cURL to get data

R

ryanmaelhorn77

Guest
I'm still trying to get this simple script to work. I swtiched over to using the cURL library on the reccomendations of others. It still isn't working though. I get no error msg when I load the page, but no data either. x10 has cURL installed, right?

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>

<h2>Data=</h2>

<?php
// Init $GetData as a cURL object
$GetData = curl_init();
// Tell cURL what URL we want to FTP
$fp = fopen(__FILE__, "r"); 
$url = "ftp://MyFTPusername:MyFTPpassword@Thumbscalp.com/Signal/test.txt"; 
curl_setopt($GetData, CURLOPT_URL, $url);  
// Tell cURL we would like the results as a string instead of just dumping it on the screen
curl_setopt($GetData, CURLOPT_RETURNTRANSFER, 1);
// Execute the cURL request
$data = curl_exec($GetData);
// Close the cURL request
curl_close($GetData);
// Display the data from the variable to ensure its there.
var_dump($data);
?>

</body>
</html>
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Do the script and test.txt exist on different hosts? If not, there's no need for cURL.

Do you have a live test page we can see?

You need to add some error handling. Test whether the result of curl_exec is False. You can use curl_error to get an error messag, but be careful that it doesn't reveal too much information.

x10 has cURL installed, right?
Calling an undefined function will result in a fatal error. Unless you've turned off all error reporting, you can be assured the cURL extension is loaded. You can always use extension_loaded to test whether or not an extension is loaded.
 
Top