curlExec() 공개 정적인 메소드

Call curl_exec() with supported redirect on safe_mode or open_basedir
저자: Naoki Sawada
public static curlExec ( resource $curl, array $options = [], array $headers = [] ) : mixed
$curl resource
$options array
$headers array
리턴 mixed
 /**
  * Call curl_exec().
  *
  * @param resource    $curl
  * @param bool|string $decodeOrParent
  * @param array       $headers
  *
  * @throws \Exception
  *
  * @return mixed
  */
 protected function _bd_curlExec($curl, $decodeOrParent = true, $headers = array())
 {
     $headers = array_merge(array('Authorization: Bearer ' . $this->token->data->access_token), $headers);
     $result = elFinder::curlExec($curl, array(), $headers);
     if (!$decodeOrParent) {
         return $result;
     }
     $decoded = json_decode($result);
     if (!empty($decoded->error_code)) {
         $errmsg = $decoded->error_code;
         if (!empty($decoded->message)) {
             $errmsg .= ': ' . $decoded->message;
         }
         throw new \Exception($errmsg);
     }
     // make catch
     if ($decodeOrParent && $decodeOrParent !== true) {
         $raws = null;
         list(, $parentId) = $this->_bd_splitPath($decodeOrParent);
         if (isset($decoded->entries)) {
             $raws = $decoded->entries;
         } elseif (isset($decoded->id)) {
             $raws = array($decoded);
         }
         if ($raws) {
             foreach ($raws as $raw) {
                 if (isset($raw->id)) {
                     $stat = $this->_bd_parseRaw($raw);
                     $itemPath = $this->_joinPath($decodeOrParent, $raw->id);
                     $this->updateCache($itemPath, $stat);
                 }
             }
         }
     }
     return $decoded;
 }