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


PHP Curl::option方法代码示例

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


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

示例3: refund

 /**
  * 退款流程
  * 
  * @param array   $order_id
  * @param array   $payment
  * @param decimal $refund_amount
  */
 public function refund($order, $payment, $refund_amount = 0)
 {
     global $db, $ecs;
     //获取pay_log记录
     $sql = "SELECT * FROM " . $ecs->table('pay_log') . " WHERE order_id = '{$order['order_id']}' AND pay_id = '{$order['pay_id']}' AND is_paid = 1 ORDER BY log_id DESC LIMIT 1";
     $log = $db->getRow($sql);
     if (empty($log)) {
         return false;
     }
     $wxtk = read_config('wxtoken');
     $payment = array_merge($payment, $wxtk);
     $amount = $refund_amount > 0 && $refund_amount < $log['order_amount'] ? $refund_amount : $log['order_amount'];
     $refund = array('appid' => $payment['appid'], 'mch_id' => $payment['wxpay_mchid'], 'op_user_id' => $payment['wxpay_mchid'], 'nonce_str' => rands(32), 'out_refund_no' => $order['order_sn'], 'out_trade_no' => $order['order_sn'], 'refund_fee' => $amount * 100, 'total_fee' => $log['order_amount'] * 100, 'transaction_id' => $log['outer_sn']);
     $refund['sign'] = $this->sign($refund, $payment['wxpay_key']);
     // 调用微信退款接口
     require_once ROOT_PATH . 'include/cls_curl.php';
     $curl = new Curl(array('server' => 'https://api.mch.weixin.qq.com', 'ssl_verify_peer' => FALSE));
     $curl->option(CURLOPT_SSLCERTTYPE, 'PEM');
     $curl->option(CURLOPT_SSLCERT, ROOT_PATH . '../data/cert/wxpay_cert.pem');
     $curl->option(CURLOPT_SSLKEYTYPE, 'PEM');
     $curl->option(CURLOPT_SSLKEY, ROOT_PATH . '../data/cert/wxpay_key.pem');
     $xml = array2xml($refund);
     //echo htmlspecialchars($xml);exit;
     $response = $curl->post('secapi/pay/refund', $xml, 'xml');
     // 检查错误
     if ($response['return_code'] == 'FAIL' || $response['result_code'] == 'FAIL') {
         $response['paytype'] = 'wxpay';
         $response['order_id'] = $order['order_id'];
         insert_error_log('refund', $response, __FILE__);
         return false;
     }
     //pay_log 插入退款记录
     insert_pay_log($order['order_id'], $amount, $order['pay_id'], PAY_ORDER, 3);
     return true;
 }
开发者ID:GYWang1983,项目名称:fruit,代码行数:42,代码来源:wxpay.php


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