Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
 /**
  * Ping API for connectivity test, and return result object.
  *
  * @author   Vova Feldman (@svovaf)
  * @since    1.0.9
  *
  * @param null|string $unique_anonymous_id
  * @param array       $params
  *
  * @return object
  */
 function ping($unique_anonymous_id = null, $params = array())
 {
     $this->_logger->entrance();
     if (self::is_temporary_down()) {
         return $this->get_temporary_unavailable_error();
     }
     $pong = is_null($unique_anonymous_id) ? Freemius_Api::Ping() : $this->_call('ping.json?' . http_build_query(array_merge(array('uid' => $unique_anonymous_id), $params)));
     if ($this->is_valid_ping($pong)) {
         return $pong;
     }
     if (self::should_try_with_http($pong)) {
         // Fallback to HTTP, since HTTPS fails.
         Freemius_Api::SetHttp();
         self::$_options->set_option('api_force_http', true, true);
         $pong = is_null($unique_anonymous_id) ? Freemius_Api::Ping() : $this->_call('ping.json?' . http_build_query(array_merge(array('uid' => $unique_anonymous_id), $params)));
         if (!$this->is_valid_ping($pong)) {
             self::$_options->set_option('api_force_http', false, true);
         }
     }
     return $pong;
 }