Created
October 2, 2010 14:20
-
-
Save lizheming/607673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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