function get_method_response_stream($method)
 {
     $request_url = '';
     switch ($method) {
         case 'products':
         case 'categories':
             $request_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/' . $method;
             break;
         default:
             return false;
     }
     $stream = null;
     try {
         if (ini_get('allow_url_fopen')) {
             $stream = fopen($request_url, 'r');
         } else {
             $response = EcwidPlatform::fetch_url($request_url);
             $body = $response['data'];
             $stream = fopen('php://temp', 'rw');
             fwrite($stream, $body);
             rewind($stream);
         }
     } catch (Exception $e) {
         $stream = null;
     }
     return $stream;
 }
 protected function trigger_auth_error($mode = 'default')
 {
     update_option('ecwid_last_oauth_fail_time', time());
     $logs = get_option('ecwid_error_log');
     if ($logs) {
         $logs = json_decode($logs);
     }
     if (is_array($logs) && count($logs) > 0) {
         $entry = $logs[count($logs) - 1];
         if (isset($entry->message)) {
             $last_error = $entry->message;
         }
     }
     if ($mode == self::MODE_RECONNECT) {
         $this->update_state(array('mode' => 'reconnect', 'error' => 'other'));
     }
     if (isset($last_error)) {
         $url = 'http://' . APP_ECWID_COM . '/script.js?805056&data_platform=wporg&data_wporg_error=' . urlencode($last_error) . '&url=' . urlencode(get_bloginfo('url'));
         EcwidPlatform::fetch_url($url);
     }
     wp_redirect('admin.php?page=ecwid&connection_error' . ($mode == self::MODE_RECONNECT ? '&reconnect' : ''));
     exit;
 }