Return to Snippet

Revision: 48478
at July 2, 2011 08:32 by zack


Initial Code
<?php
$url='http://twitter.com/statuses/user_timeline/16387631.json'; //rss link for the twitter timeline
print_r(get_data($url)); //dumps the content, you can manipulate as you wish to
 
/* gets the data from a URL */
 
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>

Initial URL
http://www.digimantra.com/technology/php/get-data-from-a-url-using-curl-php/

Initial Description


Initial Title
Get data from a URL using cURL PHP

Initial Tags


Initial Language
PHP