if (function_exists( 'curl_init' )) |
{ |
$ch = curl_init(); |
curl_setopt( $ch , CURLOPT_URL, $url_with_get ); |
curl_setopt( $ch , CURLOPT_POST, 1); |
curl_setopt( $ch , CURLOPT_POSTFIELDS, $post ); |
curl_setopt( $ch , CURLOPT_RETURNTRANSFER, true); |
$result = curl_exec( $ch ); |
curl_close( $ch ); |
} |
else |
{ |
$content = http_build_query( $post ) |
$content_length = strlen ( $content ); |
$context = |
array ( 'http' => |
array ( 'method' => 'POST' , |
'user_agent' => $user_agent , |
'header' => 'Content-Type: ' . $content_type . "\r\n" . |
'Content-Length: ' . $content_length , |
'content' => $content )); |
$context_id = stream_context_create( $context ); |
$sock = fopen ( $url_with_get , 'r' , false, $context_id ); |
$result = '' ; |
if ( $sock ) |
{ |
while (! feof ( $sock )) |
$result .= fgets ( $sock , 4096); |
fclose( $sock ); |
} |
return $result ; |
} |
} |