public static function get_request($server, $params, &$headers, &$status) { $post_string = http_build_query($params, '', '&'); $result = null; // error_log("Posting social request $post_string"); if (function_exists('curl_init')) { // Use CURL if installed... $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $server); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Ringside.API Client (curl) ' . phpversion()); curl_setopt($ch, CURLOPT_HEADER, true); $result = curl_exec($ch); $headersize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); // error_log("CURL status for $server is $status"); $http_headers = substr($result, 0, $headersize - 1); $result = substr($result, $headersize); if ($headers !== null) { $parsed_headers = RingsideSocialUtils::parse_headers($http_headers); // error_log("Render headers are"); // error_log(var_export($parsed_headers, true)); foreach ($parsed_headers as $http_header => $value) { $headers[$http_header] = $value; } } curl_close($ch); } else { // Non-CURL based version... $context = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded' . "\r\n" . 'User-Agent: OpenFB Client (non-curl) ' . phpversion() . "\r\n" . 'Content-length: ' . strlen($post_string), 'content' => $post_string)); $contextid = stream_context_create($context); $sock = fopen($server, 'r', false, $contextid); if ($sock) { $result = ''; while (!feof($sock)) { $result .= fgets($sock, 4096); } fclose($sock); } } return $result; }