示例#1
0
 /**
  * Test API connectivity.
  *
  * @since  1.0.9 If fails, try to fallback to HTTP.
  *
  * @param null|string $unique_anonymous_id
  *
  * @return bool True if successful connectivity to the API.
  */
 function test($unique_anonymous_id = null)
 {
     $this->_logger->entrance();
     $test = is_null($unique_anonymous_id) ? $this->_api->Test() : $this->_api->Test($this->_call('ping.json?uid=' . $unique_anonymous_id));
     if (false === $test && $this->_api->IsHttps()) {
         // Fallback to HTTP, since HTTPS fails.
         $this->_api->SetHttp();
         self::$_options->set_option('api_force_http', true, true);
         $test = $this->_api->Test();
     }
     return $test;
 }
示例#2
0
 /**
  * Test API connectivity.
  *
  * @since  1.0.9 If fails, try to fallback to HTTP.
  *
  * @return bool True if successful connectivity to the API.
  */
 function test()
 {
     $this->_logger->entrance();
     $test = $this->_api->Test();
     if (false === $test && $this->_api->IsHttps()) {
         // Fallback to HTTP, since HTTPS fails.
         $this->_api->SetHttp();
         self::$_options->set_option('api_force_http', true, true);
         $test = $this->_api->Test();
     }
     return $test;
 }
示例#3
0
 /**
  * Check if based on the API result we should try
  * to re-run the same request with HTTP instead of HTTPS.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.1.6
  *
  * @param $result
  *
  * @return bool
  */
 private static function should_try_with_http($result)
 {
     if (!Freemius_Api::IsHttps()) {
         return false;
     }
     return !is_object($result) || !isset($result->error) || !isset($result->error->code) || !in_array($result->error->code, array('curl_missing', 'cloudflare_ddos_protection', 'maintenance_mode', 'squid_cache_block', 'too_many_requests'));
 }