Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created Oct 2, 2010
Embed
What would you like to do?
<?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