PHP cURL

A useful PHP snippit – cURL is a multi-protocol server communication library. The code below grabs the data of a url and stores each line in an array.

?View Code PHP
1
2
3
4
5
6
7
8
9
$url = "http://google.com";
$ch = curl_init();
$timeout = 60; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$rawdata= explode("\n", curl_exec($ch));
curl_close($ch);
unset($ch);

This entry was posted on Tuesday, October 21st, 2008 at 10:45 am and is filed under Code. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

« Export MySQL Data to CSV File
MintTv »

Comments are closed.

potatoeskillme
  • Stuff

    • Building a Carputer
    • Jackson Hole Road Trip
    • Trails Highlights
    • Lake Don Pedro
    • July 4th, 2009 – 41st Newport
    • Morning Surf 7.24.09
    • Wedge 7.24.09
    • Morning Surf 7.25.09
    • Big Bear B-day Bash
    • Yosemite Aug 2009
    • NJ Surf Trip Sept 2009
    • Mammoth Thanksgiving 09
    • Jackson Hole Road Trip Redux
    • Deer Valley Spring Skiing
    • Big Bear Session
    • Sequoia 2010
    • Photos
  • Recent Posts

    • TI-86 Intervalometer for Canon XTi
    • Bad interpreter error – linux shell script
    • MintTv
    • PHP cURL
    • Export MySQL Data to CSV File
  • Categories

    • Code
    • Older Projects
    • Uncategorized
  • Links

    •  Kyle Cummings Resume
    • Alexei Udarbe
    • Evan Wise
    • John Rivas
    • Mary Redaelli