fairShareAnalyticsUrl . "companyId=" . $companyId . "&widgetType=" . $widgetType . "&actionType=" . $actionType; $responseStatus = $this->fetchContent($url); return $responseStatus; } public function logFairShareError($companyId, $widgetType, $errorType){ $url = $this->fairShareErrorLogUrl . "companyId=" . $companyId . "&widgetType=" . $widgetType . "&errorType=" . $errorType; $responseStatus = $this->fetchContent($url); return $responseStatus; } private function fetchContent($url){ if (ini_get('allow_url_fopen') == '1'){ // Open the url $fp = @fopen($url, 'r'); if ($fp) { //Set the timeout stream_set_timeout($fp, $this->TIMEOUT_SECONDS); $response = ''; // Read till EOF while ($line = fread($fp, 1024)) { $response .= $line; } $timeout = stream_get_meta_data($fp); fclose($fp); // If it timed out, return false. if ($timeout['timed_out']) { return false; } return $response; } return false; } else{ //Check if curl is installed if (function_exists('curl_init')) { $curlHandler = curl_init(); // Set the url to be the url constructed for FairShare user key validation curl_setopt($curlHandler, CURLOPT_URL, $url); // Don't return headers curl_setopt($curlHandler, CURLOPT_HEADER, 0); // Return the content as a string curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1); // Set user agent curl_setopt($curlHandler, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8'); $response = curl_exec($curlHandler); // Close the session curl_close($curlHandler); return $response; } return false; } } } ?>