当前位置: 首页>>代码示例>>PHP>>正文


PHP Cloudinary::config_get方法代码示例

本文整理汇总了PHP中Cloudinary::config_get方法的典型用法代码示例。如果您正苦于以下问题:PHP Cloudinary::config_get方法的具体用法?PHP Cloudinary::config_get怎么用?PHP Cloudinary::config_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cloudinary的用法示例。


在下文中一共展示了Cloudinary::config_get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_upload

 public function test_upload()
 {
     $result = Cloudinary\Uploader::upload("tests/logo.png");
     $this->assertEquals($result["width"], 241);
     $this->assertEquals($result["height"], 51);
     $expected_signature = Cloudinary::api_sign_request(array("public_id" => $result["public_id"], "version" => $result["version"]), Cloudinary::config_get("api_secret"));
     $this->assertEquals($result["signature"], $expected_signature);
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:8,代码来源:UploaderTest.php

示例2: setUp

 public function setUp()
 {
     Cloudinary::reset_config();
     if (!Cloudinary::config_get("api_secret")) {
         $this->markTestSkipped('Please setup environment for Upload test to run');
     }
     $this->tag = "php_test_" . time();
     Cloudinary\Uploader::upload("tests/logo.png", array("tags" => array($this->tag)));
     Cloudinary\Uploader::upload("tests/logo.png", array("tags" => array($this->tag), "width" => 10, "crop" => "scale"));
 }
开发者ID:leighvl,项目名称:cloudinary_php,代码行数:10,代码来源:ArchiveTest.php

示例3: setUp

 public function setUp()
 {
     if (!Cloudinary::config_get("api_secret")) {
         $this->markTestSkipped('Please setup environment for API test to run');
     }
     $this->api = new \Cloudinary\Api();
     if (self::$initialized) {
         return;
     }
     self::$initialized = TRUE;
     try {
         $this->api->delete_resources(array("api_test", "api_test2", "api_test3", "api_test5"));
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_transformation");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_transformation2");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_transformation3");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_upload_preset");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_upload_preset2");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_upload_preset3");
     } catch (Exception $e) {
     }
     try {
         $this->api->delete_transformation("api_test_upload_preset4");
     } catch (Exception $e) {
     }
     self::$timestamp_tag = "api_test_tag_" . time();
     \Cloudinary\Uploader::upload("tests/logo.png", array("public_id" => "api_test", "tags" => array("api_test_tag", self::$timestamp_tag), "context" => "key=value", "eager" => array("transformation" => array("width" => 100, "crop" => "scale"))));
     \Cloudinary\Uploader::upload("tests/logo.png", array("public_id" => "api_test2", "tags" => array("api_test_tag", self::$timestamp_tag), "context" => "key=value", "eager" => array("transformation" => array("width" => 100, "crop" => "scale"))));
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:46,代码来源:ApiTest.php

示例4: call_api

 function call_api($method, $uri, $params, &$options)
 {
     $prefix = \Cloudinary::option_get($options, "upload_prefix", \Cloudinary::config_get("upload_prefix", "https://api.cloudinary.com"));
     $cloud_name = \Cloudinary::option_get($options, "cloud_name", \Cloudinary::config_get("cloud_name"));
     if (!$cloud_name) {
         throw new \InvalidArgumentException("Must supply cloud_name");
     }
     $api_key = \Cloudinary::option_get($options, "api_key", \Cloudinary::config_get("api_key"));
     if (!$api_key) {
         throw new \InvalidArgumentException("Must supply api_key");
     }
     $api_secret = \Cloudinary::option_get($options, "api_secret", \Cloudinary::config_get("api_secret"));
     if (!$api_secret) {
         throw new \InvalidArgumentException("Must supply api_secret");
     }
     $api_url = implode("/", array_merge(array($prefix, "v1_1", $cloud_name), $uri));
     if ($method == "get") {
         $api_url .= "?" . preg_replace("/%5B\\d+%5D/", "%5B%5D", http_build_query($params));
     }
     $ch = curl_init($api_url);
     if ($method != "get") {
         $post_params = array();
         foreach ($params as $key => $value) {
             if (is_array($value)) {
                 $i = 0;
                 foreach ($value as $item) {
                     $post_params[$key . "[{$i}]"] = $item;
                     $i++;
                 }
             } else {
                 $post_params[$key] = $value;
             }
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
     }
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_USERPWD, "{$api_key}:{$api_secret}");
     curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cacert.pem");
     curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::userAgent());
     curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
     $response = $this->execute($ch);
     $curl_error = NULL;
     if (curl_errno($ch)) {
         $curl_error = curl_error($ch);
     }
     curl_close($ch);
     if ($curl_error != NULL) {
         throw new \Cloudinary\Api\GeneralError("Error in sending request to server - " . $curl_error);
     }
     if ($response->responseCode == 200) {
         return new \Cloudinary\Api\Response($response);
     } else {
         $exception_class = \Cloudinary::option_get(self::$CLOUDINARY_API_ERROR_CLASSES, $response->responseCode);
         if (!$exception_class) {
             throw new \Cloudinary\Api\GeneralError("Server returned unexpected status code - {$response->responseCode} - {$response->body}");
         }
         $json = $this->parse_json_response($response);
         throw new $exception_class($json["error"]["message"]);
     }
 }
开发者ID:ShanksGtr,项目名称:AdminerTest,代码行数:64,代码来源:Api.php

示例5: testSetUploadPreset

 public function testSetUploadPreset()
 {
     $api = new ApiFacade();
     $api->setUploadPreset('preset');
     $this->assertEquals('preset', \Cloudinary::config_get('upload_preset'));
 }
开发者ID:enl,项目名称:flysystem-cloudinary,代码行数:6,代码来源:ApiFacadeTest.php

示例6: call_api

 public static function call_api($action, $params, $options = array(), $file = NULL)
 {
     $return_error = \Cloudinary::option_get($options, "return_error");
     if (!\Cloudinary::option_get($options, "unsigned")) {
         $params = \Cloudinary::sign_request($params, $options);
     }
     $api_url = \Cloudinary::cloudinary_api_url($action, $options);
     $ch = curl_init($api_url);
     $post_params = array();
     foreach ($params as $key => $value) {
         if (is_array($value)) {
             $i = 0;
             foreach ($value as $item) {
                 $post_params[$key . "[{$i}]"] = $item;
                 $i++;
             }
         } else {
             $post_params[$key] = $value;
         }
     }
     if ($file) {
         if (!preg_match('/^@|^ftp:|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\\/+\\n=]+)$/', $file)) {
             if (function_exists("curl_file_create")) {
                 $post_params['file'] = curl_file_create($file);
                 $post_params['file']->setPostFilename($file);
             } else {
                 $post_params["file"] = "@" . $file;
             }
         } else {
             $post_params["file"] = $file;
         }
     }
     curl_setopt($ch, CURLOPT_POST, true);
     $timeout = \Cloudinary::option_get($options, "timeout", \Cloudinary::config_get("timeout", 60));
     curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
     curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "cacert.pem");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     # no effect since PHP 5.1.3
     curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::userAgent());
     curl_setopt($ch, CURLOPT_PROXY, \Cloudinary::option_get($options, "api_proxy", \Cloudinary::config_get("api_proxy")));
     $range = \Cloudinary::option_get($options, "content_range");
     if ($range != NULL) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Range: ' . $range));
     }
     $response = curl_exec($ch);
     $curl_error = NULL;
     if (curl_errno($ch)) {
         $curl_error = curl_error($ch);
     }
     $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     $response_data = $response;
     curl_close($ch);
     if ($curl_error != NULL) {
         throw new \Cloudinary\Error("Error in sending request to server - " . $curl_error);
     }
     if ($code != 200 && $code != 400 && $code != 500 && $code != 401 && $code != 404) {
         throw new \Cloudinary\Error("Server returned unexpected status code - " . $code . " - " . $response_data, $code);
     }
     $result = json_decode($response_data, TRUE);
     if ($result == NULL) {
         throw new \Cloudinary\Error("Error parsing server response (" . $code . ") - " . $response_data);
     }
     if (isset($result["error"])) {
         if ($return_error) {
             $result["error"]["http_code"] = $code;
         } else {
             throw new \Cloudinary\Error($result["error"]["message"], $code);
         }
     }
     return $result;
 }
开发者ID:IVsevolod,项目名称:zouk,代码行数:72,代码来源:Uploader.php

示例7: ewww_image_optimizer_options


//.........这里部分代码省略.........
    ?>
 /></td></tr>
				<tr class="nocloud"><th><label for="ewww_image_optimizer_disable_optipng"><?php 
    _e('disable', EWWW_IMAGE_OPTIMIZER_DOMAIN);
    ?>
 optipng</label></th><td><input type="checkbox" id="ewww_image_optimizer_disable_optipng" name="ewww_image_optimizer_disable_optipng" <?php 
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_disable_optipng') == TRUE) {
        ?>
checked="true"<?php 
    }
    ?>
 /></td></tr>
				<tr class="nocloud"><th><label for="ewww_image_optimizer_disable_pngout"><?php 
    _e('disable', EWWW_IMAGE_OPTIMIZER_DOMAIN);
    ?>
 pngout</label></th><td><input type="checkbox" id="ewww_image_optimizer_disable_pngout" name="ewww_image_optimizer_disable_pngout" <?php 
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_disable_pngout') == TRUE) {
        ?>
checked="true"<?php 
    }
    ?>
 /></td><tr>
				<tr class="nocloud"><th><label for="ewww_image_optimizer_disable_gifsicle"><?php 
    _e('disable', EWWW_IMAGE_OPTIMIZER_DOMAIN);
    ?>
 gifsicle</label></th><td><input type="checkbox" id="ewww_image_optimizer_disable_gifsicle" name="ewww_image_optimizer_disable_gifsicle" <?php 
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_disable_gifsicle') == TRUE) {
        ?>
checked="true"<?php 
    }
    ?>
 /></td></tr>
<?php 
    if (class_exists('Cloudinary') && Cloudinary::config_get("api_secret")) {
        ?>
				<tr><th><label for="ewww_image_optimizer_enable_cloudinary"><?php 
        _e('Automatic Cloudinary upload', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        ?>
</label></th><td><input type="checkbox" id="ewww_image_optimizer_enable_cloudinary" name="ewww_image_optimizer_enable_cloudinary" value="true" <?php 
        if (ewww_image_optimizer_get_option('ewww_image_optimizer_enable_cloudinary') == TRUE) {
            ?>
checked="true"<?php 
        }
        ?>
 /> <?php 
        _e('When enabled, uploads to the Media Library will be transferred to Cloudinary after optimization. Cloudinary generates resizes, so only the full-size image is uploaded.', EWWW_IMAGE_OPTIMIZER_DOMAIN);
        ?>
</td></tr>
<?php 
    }
    ?>
			</table>
			</div>
			<h3><?php 
    _e('Optimization Settings', EWWW_IMAGE_OPTIMIZER_DOMAIN);
    ?>
</h3>
			<div>
			<table class="form-table">
				<tr><th><label for="ewww_image_optimizer_jpegtran_copy"><?php 
    _e('Remove metadata', EWWW_IMAGE_OPTIMIZER_DOMAIN);
    ?>
</label></th>
				<td><input type="checkbox" id="ewww_image_optimizer_jpegtran_copy" name="ewww_image_optimizer_jpegtran_copy" value="true" <?php 
    if (ewww_image_optimizer_get_option('ewww_image_optimizer_jpegtran_copy') == TRUE) {
        ?>
开发者ID:LacieNat,项目名称:Access-Comm-Project,代码行数:67,代码来源:ewww-image-optimizer.php

示例8: isset

    <?php 
$unsigned = isset($_GET["unsigned"]) && $_GET["unsigned"] == "1";
?>
    <div id='direct_upload'>
      <h1>Direct <?php 
if ($unsigned) {
    echo "unsigned ";
}
?>
upload from the browser</h1>
      <form>
      <?php 
if ($unsigned) {
    # For the sake of simplicity of the sample site, we generate the preset on the fly. It only needs to be created once, in advance.
    $api = new \Cloudinary\Api();
    $upload_preset = "sample_" . substr(sha1(Cloudinary::config_get("api_key") . Cloudinary::config_get("api_secret")), 0, 10);
    try {
        $api->upload_preset($upload_preset);
    } catch (\Cloudinary\Api\NotFound $e) {
        $api->create_upload_preset(array("name" => $upload_preset, "unsigned" => TRUE, "folder" => "preset_folder"));
    }
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_unsigned_image_upload_tag('test', $upload_preset, array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
} else {
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_image_upload_tag('test', array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
}
?>
      <a href="?unsigned=<?php 
开发者ID:cloudinary,项目名称:cloudinary_php,代码行数:31,代码来源:upload.php

示例9: ewww_image_optimizer_resize_from_meta_data


//.........这里部分代码省略.........
        $new_file = substr($meta['file'], 0, -3);
        // change extension
        $new_ext = substr($file, -3);
        $meta['file'] = $new_file . $new_ext;
        $ewww_debug .= "image was converted<br>";
        // if we don't already have the update attachment filter
        if (FALSE === has_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment')) {
            // add the update attachment filter
            add_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10, 2);
        }
        // store the conversion status in the metadata
        $meta['converted'] = 1;
        // store the old filename in the database
        $meta['orig_file'] = $original;
    } else {
        remove_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10);
    }
    // resized versions, so we can continue
    if (isset($meta['sizes'])) {
        $ewww_debug .= "processing resizes<br>";
        // meta sizes don't contain a path, so we calculate one
        if ($gallery_type === 6) {
            $base_dir = dirname($file_path) . '/_resized/';
        } else {
            $base_dir = dirname($file_path) . '/';
        }
        // process each resized version
        $processed = array();
        foreach ($meta['sizes'] as $size => $data) {
            // initialize $dup_size
            $dup_size = false;
            // check through all the sizes we've processed so far
            foreach ($processed as $proc => $scan) {
                // if a previous resize had identical dimensions
                if ($scan['height'] == $data['height'] && $scan['width'] == $data['width']) {
                    // found a duplicate resize
                    $dup_size = true;
                    // point this resize at the same image as the previous one
                    $meta['sizes'][$size]['file'] = $meta['sizes'][$proc]['file'];
                    // and tell the user we didn't do any further optimization
                    $meta['sizes'][$size]['ewww_image_optimizer'] = __('No savings', EWWW_IMAGE_OPTIMIZER_DOMAIN);
                }
            }
            // if this is a unique size
            if (!$dup_size) {
                $resize_path = $base_dir . $data['file'];
                // run the optimization and store the results
                list($optimized_file, $results, $resize_conv, $original) = ewww_image_optimizer($resize_path, $gallery_type, $conv, $new_image);
                // if the resize was converted, store the result and the original filename in the metadata for later recovery
                if ($resize_conv) {
                    // if we don't already have the update attachment filter
                    if (FALSE === has_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment')) {
                        // add the update attachment filter
                        add_filter('wp_update_attachment_metadata', 'ewww_image_optimizer_update_attachment', 10, 2);
                    }
                    $meta['sizes'][$size]['converted'] = 1;
                    $meta['sizes'][$size]['orig_file'] = str_replace($base_dir, '', $original);
                    $ewww_debug .= "original filename: {$original}<br>";
                    $meta['sizes'][$size]['real_orig_file'] = str_replace($base_dir, '', $resize_path);
                    $ewww_debug .= "resize path: {$resize_path}<br>";
                }
                // update the filename
                $meta['sizes'][$size]['file'] = str_replace($base_dir, '', $optimized_file);
                // update the optimization results
                $meta['sizes'][$size]['ewww_image_optimizer'] = $results;
            }
            // store info on the sizes we've processed, so we can check the list for duplicate sizes
            $processed[$size]['width'] = $data['width'];
            $processed[$size]['height'] = $data['height'];
        }
    }
    if (class_exists('Cloudinary') && Cloudinary::config_get("api_secret") && ewww_image_optimizer_get_option('ewww_image_optimizer_enable_cloudinary') && !empty($new_image)) {
        try {
            $result = CloudinaryUploader::upload($file, array('use_filename' => True));
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
        if (!empty($error)) {
            $ewww_debug .= "Cloudinary error: {$error}<br>";
        } else {
            $ewww_debug .= "successfully uploaded to Cloudinary<br>";
            // register the attachment in the database as a cloudinary attachment
            $old_url = wp_get_attachment_url($ID);
            wp_update_post(array('ID' => $ID, 'guid' => $result['url']));
            update_attached_file($ID, $result['url']);
            $meta['cloudinary'] = TRUE;
            $errors = array();
            // update the image location for the attachment
            CloudinaryPlugin::update_image_src_all($ID, $result, $old_url, $result["url"], TRUE, $errors);
            if (count($errors) > 0) {
                $ewww_debug .= "Cannot migrate the following posts:<br>" . implode("<br>", $errors);
            }
        }
    }
    if ($log) {
        ewww_image_optimizer_debug_log();
    }
    // send back the updated metadata
    return $meta;
}
开发者ID:LacieNat,项目名称:Access-Comm-Project,代码行数:101,代码来源:common.php

示例10: test_upload_timeout

 /**
  * @expectedException Cloudinary\Error
  * @expectedExceptionMessage timed out
  */
 function test_upload_timeout()
 {
     $timeout = Cloudinary::config_get("timeout");
     Cloudinary::config(array("timeout" => 0.01));
     $this->assertEquals(Cloudinary::config_get("timeout"), 0.01);
     try {
         \Cloudinary\Uploader::upload("tests/logo.png");
     } finally {
         Cloudinary::config(array("timeout", $timeout));
     }
 }
开发者ID:kedweber,项目名称:cloudinary_php,代码行数:15,代码来源:UploaderTest.php

示例11: array

<?php

require 'main.php';
# You can add here your custom verification code
# Check for a valid Cloudinary response
$api_secret = Cloudinary::config_get("api_secret");
if (!$api_secret) {
    throw new \InvalidArgumentException("Must supply api_secret");
}
$existing_signature = \Cloudinary::option_consume($_POST, "signature");
$to_sign = array('public_id' => $_POST['public_id'], 'version' => $_POST['version']);
$calculated_signature = \Cloudinary::api_sign_request($to_sign, $api_secret);
if ($existing_signature == $calculated_signature) {
    # Create a model record using the data received (best practice is to save locally
    # only data needed for reaching the image on Cloudinary - public_id and version;
    # and fields that might be needed for your application (e.g.,), width, height)
    $photo = \PhotoAlbum\create_photo_model($_POST);
} else {
    error_log("Received signature verficiation failed (" . $existing_signature . " != " . $calculated_signature . "). data: " . \PhotoAlbum\ret_var_dump($_POST));
}
开发者ID:hidayat365,项目名称:phpindonesia.or.id-membership2,代码行数:20,代码来源:upload_complete.php

示例12: assertUrl

function assertUrl($test, $path, $message = '')
{
    $cloud_name = \Cloudinary::config_get("cloud_name");
    $test->assertEquals("/v1_1/" . $cloud_name . $path, Curl::$instance->url_path(), $message);
}
开发者ID:cloudinary,项目名称:cloudinary_php,代码行数:5,代码来源:TestHelper.php

示例13: testCloudinaryConfig

 /**
  * Test the cloudinary config
  *
  * @return void
  * @author Andrew Lowther <andrew.lowther@mademedia.co.uk>
  **/
 public function testCloudinaryConfig()
 {
     $this->assertTrue(\Cloudinary::config_get('cloud_name') === $this->config['cloud_name']);
     $this->assertTrue(\Cloudinary::config_get('api_key') === $this->config['api_key']);
     $this->assertTrue(\Cloudinary::config_get('api_secret') === $this->config['api_secret']);
 }
开发者ID:helpfulrobot,项目名称:andrewlowther-mediamanager,代码行数:12,代码来源:CloudinarySimpleImageTest.php

示例14: prepare_cloudinary_media_lib_url

 function prepare_cloudinary_media_lib_url($mode)
 {
     if (!$this->configured()) {
         return NULL;
     }
     $params = array("timestamp" => time(), "mode" => $mode, "plugin_version" => cloudinary_VERSION);
     $params["signature"] = Cloudinary::api_sign_request($params, Cloudinary::config_get("api_secret"));
     $params["api_key"] = Cloudinary::config_get("api_key");
     $query = http_build_query($params);
     return CLOUDINARY_BASE_URL . "/console/media_library/cms?{$query}";
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:11,代码来源:cloudinary.php

示例15: call_api

 protected function call_api($method, $uri, $params, &$options)
 {
     $prefix = Cloudinary::option_get($options, "upload_prefix", Cloudinary::config_get("upload_prefix", "https://api.cloudinary.com"));
     $cloud_name = Cloudinary::option_get($options, "cloud_name", Cloudinary::config_get("cloud_name"));
     if (!$cloud_name) {
         throw new InvalidArgumentException("Must supply cloud_name");
     }
     $api_key = Cloudinary::option_get($options, "api_key", Cloudinary::config_get("api_key"));
     if (!$api_key) {
         throw new InvalidArgumentException("Must supply api_key");
     }
     $api_secret = Cloudinary::option_get($options, "api_secret", Cloudinary::config_get("api_secret"));
     if (!$api_secret) {
         throw new InvalidArgumentException("Must supply api_secret");
     }
     $api_url = implode("/", array_merge(array($prefix, "v1_1", $cloud_name), $uri));
     $api_url .= "?" . preg_replace("/%5B\\d+%5D/", "%5B%5D", http_build_query($params));
     $ch = curl_init($api_url);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($ch, CURLOPT_USERPWD, $api_key . ":" . $api_secret);
     curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__)) . "/cacert.pem");
     $response = $this->execute($ch);
     curl_close($ch);
     if ($response->responseCode == 200) {
         return new CloudinaryApiResponse($response);
     } else {
         $exception_class = Cloudinary::option_get(self::$CLOUDINARY_API_ERROR_CLASSES, $response->responseCode);
         if (!$exception_class) {
             throw new CloudinaryApiGeneralError("Server returned unexpected status code - {$response->responseCode} - {$response->body}");
         }
         $json = $this->parse_json_response($response);
         throw new $exception_class($json["error"]["message"]);
     }
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:38,代码来源:api.php


注:本文中的Cloudinary::config_get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。