 |
Results from the most recent live auction are here.
23 members in the live chat room. Join Chat!
| |
04-29-2008, 07:11 AM
|
· #1 | | New Member | CURL alternative to fopen - revisited Hello!
There is already a thread that was created that touched on this issue, but it was locked.
My host provider is no longer allowing fopen and fgets command calls due to security issues and CURL was suggested as an alternative method to achieve the same results.
Here is a snippet of the code which is giving errors in my php script: Code:
if($address!='')
{
$fp = fopen($address,"r");
$i=0;
while($i<1000){
$html_data.=fgets($fp);
$i++;
}
I know this is probably a very simple fix, but my knowledge of CURL is limited at best, any help would be appreciated! Thank you.
Last edited by Hossam : 04-29-2008 at 07:17 AM.
|
| |
04-29-2008, 08:44 AM
|
· #2 | | Danltn.com Name: Daniel Neville Location: Danltn.com / Nottingham, UK Join Date: May 2007
Posts: 1,185
NP$: 681.56 ( Donate)
| |
| |
04-29-2008, 10:17 AM
|
· #3 | | New Member | Darn, i tried this but I don't get the result as the prior script PHP Code: if($address!='')
{
$fp = curl_init();
curl_setopt($fp, CURLOPT_URL, $address);
curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($fp, CURLOPT_FORBID_REUSE, true);
curl_setopt($fp, CURLOPT_FRESH_CONNECT, true);
curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($fp, CURLOPT_TIMEOUT, 10);
curl_setopt($fp, CURLOPT_HTTPHEADER, array('Connection: close'));
$html_data = curl_exec($fp);
}
The page renders blank! Any suggestions?
Last edited by Hossam : 04-29-2008 at 11:37 AM.
|
| |
04-30-2008, 12:20 AM
|
· #4 | | xrvel is cruel :-) Location: Indonesia Join Date: Nov 2007
Posts: 889
NP$: 713.06 ( Donate)
| This should work PHP Code: $curlurl = 'http://something.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $curlurl);
curl_setopt($ch, CURLOPT_REFERER, $curlurl);
curl_setopt($ch, CURLOPT_USERAGENT, getenv('HTTP_USER_AGENT'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$curlresult = curl_exec($ch);
curl_close($ch);
echo($curlresult);
__________________ Xrvel 
Signature #2
|
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |