Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created October 2, 2010 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizheming/607673 to your computer and use it in GitHub Desktop.
Save lizheming/607673 to your computer and use it in GitHub Desktop.
<?php
define(P2_PATH,'http://pagecookery.net/'); // please change to your P2 path, remember the ending slash.
function pcurl($url,$postargs=false)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$response = curl_exec($ch);
$responseInfo=curl_getinfo($ch);
curl_close($ch);
if( intval( $responseInfo['http_code'] ) == 200 )
return $response;
else
return false;
}
function readit()
{
$request = P2_PATH.'api.php';
$result = pcurl( $request );
if ($result) return $result;
else return false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment