<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,‘Sci/Tech - Google News output=rss’);
$fp = fopen(‘rss.xml’, ‘w’);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);
?>
I got the error msg as:
Parse error: syntax error, unexpected ':' in C:\xampp\htdocs\projects\test\cur.php on line 3
3 replies to this topic
#1
Posted 14 November 2011 - 11:43 PM
|
|
|
#2
Posted 15 November 2011 - 01:57 AM
This may help
<?php
/**
* Initialize the cURL session
*/
$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss');
/**
* Create a new file
*/
$fp = fopen('rss.xml', 'w');
/**
* Ask cURL to write the contents to a file
*/
curl_setopt($ch, CURLOPT_FILE, $fp);
/**
* Execute the cURL session
*/
curl_exec ($ch);
/**
* Close cURL session and file
*/
curl_close ($ch);
fclose($fp);
?>
<?php
/**
* Initialize the cURL session
*/
$ch = curl_init();
/**
* Set the URL of the page or file to download.
*/
curl_setopt($ch, CURLOPT_URL,
'http://news.google.com/news?hl=en&topic=t&output=rss');
/**
* Create a new file
*/
$fp = fopen('rss.xml', 'w');
/**
* Ask cURL to write the contents to a file
*/
curl_setopt($ch, CURLOPT_FILE, $fp);
/**
* Execute the cURL session
*/
curl_exec ($ch);
/**
* Close cURL session and file
*/
curl_close ($ch);
fclose($fp);
?>
#3
Posted 15 November 2011 - 02:20 AM
First of all,thanks for ur reply....
ya its executed....
Since i'm a fresher,i dnt know how to display the data...
ya its executed....
Since i'm a fresher,i dnt know how to display the data...
#4
Posted 15 November 2011 - 05:11 AM
You can directly echo the data by putting this:
echo curl_exec ($ch);
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









