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


PHP Cloudinary::cloudinary_api_url方法代码示例

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


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

示例1: cl_form_tag

 function cl_form_tag($callback_url, $options = array())
 {
     $form_options = Cloudinary::option_get($options, "form", array());
     $options["callback_url"] = $callback_url;
     $params = Cloudinary\Uploader::build_upload_params($options);
     $params = Cloudinary::sign_request($params, $options);
     $api_url = Cloudinary::cloudinary_api_url("upload", $options);
     $form = "<form enctype='multipart/form-data' action='" . $api_url . "' method='POST' " . Cloudinary::html_attrs($form_options) . ">\n";
     foreach ($params as $key => $value) {
         $form .= "<input " . Cloudinary::html_attrs(array("name" => $key, "value" => $value, "type" => "hidden")) . "/>\n";
     }
     $form .= "</form>\n";
     return $form;
 }
开发者ID:cloudinary,项目名称:cloudinary_php,代码行数:14,代码来源:Helpers.php

示例2: private_download_url

 public static function private_download_url($public_id, $format, $options = array())
 {
     $cloudinary_params = Cloudinary::sign_request(array("timestamp" => time(), "public_id" => $public_id, "format" => $format, "type" => Cloudinary::option_get($options, "type"), "attachment" => Cloudinary::option_get($options, "attachment"), "expires_at" => Cloudinary::option_get($options, "expires_at")), $options);
     return Cloudinary::cloudinary_api_url("download", $options) . "?" . http_build_query($cloudinary_params);
 }
开发者ID:ShanksGtr,项目名称:AdminerTest,代码行数:5,代码来源:Cloudinary.php

示例3: 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);
     # Serialize params
     $api_url .= "?" . preg_replace("/%5B\\d+%5D/", "%5B%5D", http_build_query($params));
     $ch = curl_init($api_url);
     $post_params = array();
     if ($file) {
         if (!preg_match('/^@|^https?:|^s3:|^data:[^;]*;base64,([a-zA-Z0-9\\/+\\n=]+)$/', $file)) {
             if (function_exists("curl_file_create")) {
                 $post_params['file'] = curl_file_create($file);
             } else {
                 $post_params["file"] = "@" . $file;
             }
         } else {
             $post_params["file"] = $file;
         }
     }
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     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);
     curl_setopt($ch, CURLOPT_USERAGENT, \Cloudinary::USER_AGENT);
     $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:uiDeveloper116,项目名称:webstore,代码行数:55,代码来源:Uploader.php

示例4: 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

示例5: call_api

 public static function call_api($action, $params, $options = array(), $file = NULL)
 {
     $return_error = Cloudinary::option_get($options, "return_error");
     $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");
     }
     $params["signature"] = Cloudinary::api_sign_request($params, $api_secret);
     $params["api_key"] = $api_key;
     # Remove blank parameters
     $params = array_filter($params);
     $api_url = Cloudinary::cloudinary_api_url($action, $options);
     $api_url .= "?" . preg_replace("/%5B\\d+%5D/", "%5B%5D", http_build_query($params));
     $ch = curl_init($api_url);
     $post_params = array();
     if ($file) {
         if (!preg_match('/^@|^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);
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
     curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__)) . "/cacert.pem");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERAGENT, Cloudinary::USER_AGENT);
     $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 Exception("Error in sending request to server - " . $curl_error);
     }
     if ($code != 200 && $code != 400 && $code != 500 && $code != 401 && $code != 404) {
         throw new Exception("Server returned unexpected status code - " . $code . " - " . $response_data);
     }
     $result = json_decode($response_data, TRUE);
     if ($result == NULL) {
         throw new Exception("Error parsing server response (" . $code . ") - " . $response_data);
     }
     if (isset($result["error"])) {
         if ($return_error) {
             $result["error"]["http_code"] = $code;
         } else {
             throw new Exception($result["error"]["message"]);
         }
     }
     return $result;
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:64,代码来源:uploader.php


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