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


PHP Curl::create方法代码示例

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


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

示例1: initialize

 function initialize()
 {
     if (!$this->fetched) {
         $config =& get_config();
         $assetUrl = $config['asset_service'] . $this->node['AssetID'];
         $curl = new Curl();
         $curl->create($assetUrl);
         $curl->option(CURLOPT_HEADER, true);
         $curl->option(CURLOPT_NOBODY, true);
         $response = $curl->execute();
         if ($response) {
             $headers = http_parse_headers($response);
             $this->size = $headers['Content-Length'];
             $this->contentType = $headers['Content-Type'];
             if (isset($headers['ETag'])) {
                 $this->etag = $headers['ETag'];
             } else {
                 if (isset($headers['Etag'])) {
                     $this->etag = $headers['Etag'];
                 } else {
                     $this->etag = '';
                 }
             }
         } else {
             log_message('error', "InventoryFile: Failed to fetch headers from {$assetUrl}");
         }
         $this->fetched = true;
     }
 }
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:29,代码来源:Class.InventoryFile.php

示例2: execute

 function execute($method, $url, $fields = '', $userAgent = '', $httpHeaders = '', $username = '', $password = '')
 {
     $ch = Curl::create();
     if (false === $ch) {
         return false;
     }
     if (is_string($url) && strlen($url)) {
         $ret = curl_setopt($ch, CURLOPT_URL, $url);
     } else {
         return false;
     }
     //是否显示头部信息
     curl_setopt($ch, CURLOPT_HEADER, false);
     //
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if ($username != '') {
         curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
     }
     $method = strtolower($method);
     if ('post' == $method) {
         curl_setopt($ch, CURLOPT_POST, true);
         if (is_array($fields)) {
             $sets = array();
             foreach ($fields as $key => $val) {
                 $sets[] = $key . '=' . urlencode($val);
             }
             $fields = implode('&', $sets);
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
     } else {
         if ('put' == $method) {
             curl_setopt($ch, CURLOPT_PUT, true);
         }
     }
     //curl_setopt($ch, CURLOPT_PROGRESS, true);
     //curl_setopt($ch, CURLOPT_VERBOSE, true);
     //curl_setopt($ch, CURLOPT_MUTE, false);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     //设置curl超时秒数,例如将信息POST出去3秒钟后自动结束运行。
     if (strlen($userAgent)) {
         curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
     }
     if (is_array($httpHeaders)) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
     }
     $ret = curl_exec($ch);
     if (curl_errno($ch)) {
         curl_close($ch);
         return array(curl_error($ch), curl_errno($ch));
     } else {
         curl_close($ch);
         if (!is_string($ret) || !strlen($ret)) {
             return false;
         }
         return $ret;
     }
 }
开发者ID:Bingle-labake,项目名称:coollive.com.cn,代码行数:57,代码来源:curl.php

示例3: create_asset

function create_asset($assetID, $creatorID, $contentType, $filename)
{
    $CI =& get_instance();
    $CI->load->library('Curl');
    $CI->load->helper('path');
    $filename = rtrim(set_realpath($filename), '/');
    $params = array('AssetID' => $assetID, 'CreatorID' => $creatorID, 'Asset' => "@{$filename};type={$contentType}");
    echo 'Posting ' . $filename . ' to ' . $CI->config->item('asset_service') . '<br/>';
    $curl = new Curl();
    $curl->create($CI->config->item('asset_service'));
    $curl->option(CURLOPT_POST, TRUE);
    $curl->option(CURLOPT_POSTFIELDS, $params);
    $curl->http_method('post');
    $response = json_decode($curl->execute(), TRUE);
    if (!isset($response)) {
        $response = array('Message' => 'Invalid or missing response. ' . $curl->error_string);
    }
    return $response;
}
开发者ID:QuillLittlefeather,项目名称:mgm-simiangrid,代码行数:19,代码来源:simian_helper.php

示例4: run

 /**
  * 请求
  * @param type $data
  * @return type
  */
 private function run($data)
 {
     $curl = new \Curl();
     $fields = array('data' => json_encode($data), 'version' => SHUIPF_VERSION, 'act' => $this->act, 'identity' => $this->getIdentity(), 'token' => $this->token);
     //curl支持 检测
     if ($curl->create() == false) {
         $this->error = '服务器不支持Curl扩展!';
         return false;
     }
     //请求
     $status = $curl->post(self::serverHot, $fields);
     if (false == $status) {
         $this->error = '无法联系服务器,请稍后再试!';
         return false;
     }
     return $this->returnResolve($status);
 }
开发者ID:sandom123,项目名称:king400,代码行数:22,代码来源:Cloud.class.php

示例5: NOW

 $sql = "SELECT Resource FROM Capabilities WHERE ID=:ID AND ExpirationDate > NOW() LIMIT 1";
 $sth = $db->prepare($sql);
 if ($sth->execute(array(':ID' => $_GET['cap']))) {
     if ($sth->rowCount() > 0) {
         $obj = $sth->fetchObject();
         $resourceURL = $obj->Resource;
         // TODO: Handle relative resource URLs
         if (stripos($_SERVER['REQUEST_METHOD'], 'POST') !== FALSE) {
             // FIXME: Implement POST capability routing
             $curl = new Curl();
             $curl->create($resourceURL);
         } else {
             if (stripos($_SERVER['REQUEST_METHOD'], 'GET') !== FALSE) {
                 // FIXME: Properly proxy response codes
                 $curl = new Curl();
                 $curl->create($resourceURL);
                 echo $curl->execute();
                 exit;
             } else {
                 log_message('warn', "Don't know how to route method " . $_SERVER['REQUEST_METHOD'] . " for capability {$resourceURL}");
                 header("HTTP/1.1 400 Bad Request");
                 echo 'Request method not understood';
                 exit;
             }
         }
     } else {
         log_message('warn', "Capability " . $_GET['cap'] . " not found");
         header("HTTP/1.1 404 Not Found");
         echo 'Capability not found';
         exit;
     }
开发者ID:ronfesta,项目名称:simiangrid,代码行数:31,代码来源:index.php


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