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


PHP Curl::setHeader方法代码示例

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


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

示例1: create

 public static function create($apiKey, $endpoint = self::DEFAULT_ENDPOINT, $version = '1.0')
 {
     $curl = new Curl();
     if (strpos($endpoint, 'https') === 0) {
         $curl->setOpt(CURLOPT_CAINFO, __DIR__ . '/resources/cacert.pem');
     }
     $curl->setHeader('X-Auth-Key', $apiKey);
     $curl->setHeader('Content-Type', 'application/json');
     $connector = new Connector($curl, $apiKey, $version, $endpoint);
     $parser = new Parser();
     $errorHandler = new ErrorHandler();
     return new IUcto($connector, $parser, $errorHandler);
 }
开发者ID:iUcto,项目名称:php-sdk,代码行数:13,代码来源:IUctoFactory.php

示例2: post

 public static function post($path, $data)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->post(\Slim\Slim::getInstance()->globalConfig['oaUrl'] . $path, $data);
     return json_decode($curl->response->json, TRUE);
 }
开发者ID:aslijiasheng,项目名称:jacksonslim,代码行数:7,代码来源:CurlPlugin.class.php

示例3: testHeaders

 public function testHeaders()
 {
     $this->curl->setHeader('Content-Type', 'application/json');
     $this->curl->setHeader('X-Requested-With', 'XMLHttpRequest');
     $this->curl->setHeader('Accept', 'application/json');
     $this->assertTrue($this->server('GET', array('test' => 'server', 'key' => 'CONTENT_TYPE')) === 'application/json');
     $this->assertTrue($this->server('GET', array('test' => 'server', 'key' => 'HTTP_X_REQUESTED_WITH')) === 'XMLHttpRequest');
     $this->assertTrue($this->server('GET', array('test' => 'server', 'key' => 'HTTP_ACCEPT')) === 'application/json');
 }
开发者ID:php-mod,项目名称:curl,代码行数:9,代码来源:CurlTest.php

示例4: array

 static function mapi_get($url_mixed, $data = array(), $debug = false)
 {
     //$debug=true;
     Yii::import('application.vendors.*');
     require_once 'Tp/Curl.class.php';
     $curl = new Curl();
     if (YII_ENV == 'development') {
         $curl->setHeader('Apihandshake', 'yaochufa');
         $curl->setHeader('Referer', 'http://m.yaochufa.com');
     } else {
         $curl->setHeader('Apihandshake', 'yaochufaapi');
         $curl->setHeader('Referer', 'http://m.yaochufa.com');
     }
     $curl->setOpt(CURLOPT_TIMEOUT, 15);
     $data['system'] = Yii::app()->params['mmm_api']['system'];
     $curl->get($url_mixed, $data);
     if ($debug == true) {
         XUtils::dump($curl->request_headers);
     }
     return $curl->response;
 }
开发者ID:mgcxy,项目名称:yiiSwoole,代码行数:21,代码来源:XHttp.php

示例5: ip

 public static function ip($ip)
 {
     $url = 'http://apis.baidu.com/rtbasia/ip_type/ip_type?ip=' . $ip;
     $curl = new Curl();
     $curl->setHeader("apikey", "29ddcb64dbe2f42764115b28941d2154");
     $curl->get($url);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
开发者ID:oyoy8629,项目名称:test,代码行数:13,代码来源:IpType.php

示例6: addPut

 /**
  * Add Put
  *
  * @access public
  * @param  $url
  * @param  $data
  *
  * @return object
  */
 public function addPut($url, $data = array())
 {
     if (is_array($url)) {
         $data = $url;
         $url = $this->baseUrl;
     }
     $curl = new Curl();
     $curl->setURL($url);
     $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT');
     $put_data = $curl->buildPostData($data);
     $curl->setHeader('Content-Length', strlen($put_data));
     $curl->setOpt(CURLOPT_POSTFIELDS, $put_data);
     $this->addHandle($curl);
     return $curl;
 }
开发者ID:AlusaChen,项目名称:alusachen.com,代码行数:24,代码来源:MultiCurl.php

示例7: addSearch

 /**
  * Add Search
  *
  * @access public
  * @param  $url
  * @param  $data
  *
  * @return object
  */
 public function addSearch($url, $data = array())
 {
     if (is_array($url)) {
         $data = $url;
         $url = $this->baseUrl;
     }
     $curl = new Curl();
     $curl->setUrl($url);
     $curl->setOpt(CURLOPT_CUSTOMREQUEST, 'SEARCH');
     $put_data = $curl->buildPostData($data);
     if (is_string($put_data)) {
         $curl->setHeader('Content-Length', strlen($put_data));
     }
     $curl->setOpt(CURLOPT_POSTFIELDS, $put_data);
     $this->queueHandle($curl);
     return $curl;
 }
开发者ID:zachborboa,项目名称:php-curl-class,代码行数:26,代码来源:MultiCurl.php

示例8: Curl

<?php

require '../src/Curl.class.php';
define('API_KEY', '');
define('API_SECRET', '');
$url = 'https://coinbase.com/api/v1/account/balance';
$nonce = (int) (microtime(true) * 1000000.0);
$message = $nonce . $url;
$signature = hash_hmac('sha256', $message, API_SECRET);
$curl = new Curl();
$curl->setHeader('ACCESS_KEY', API_KEY);
$curl->setHeader('ACCESS_SIGNATURE', $signature);
$curl->setHeader('ACCESS_NONCE', $nonce);
$curl->get($url);
echo 'My current account balance at Coinbase is ' . $curl->response->amount . ' ' . $curl->response->currency . '.' . "\n";
开发者ID:canerdogan,项目名称:php-curl-class,代码行数:15,代码来源:coinbase_account_balance.php

示例9: testErrorCallback

 public function testErrorCallback()
 {
     $success_called = FALSE;
     $error_called = FALSE;
     $complete_called = FALSE;
     $curl = new Curl();
     $curl->setHeader('X-DEBUG-TEST', 'get');
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE);
     $curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 2000);
     $curl->success(function ($instance) use(&$success_called, &$error_called, &$complete_called) {
         PHPUnit_Framework_Assert::assertInstanceOf('Curl', $instance);
         PHPUnit_Framework_Assert::assertFalse($success_called);
         PHPUnit_Framework_Assert::assertFalse($error_called);
         PHPUnit_Framework_Assert::assertFalse($complete_called);
         $success_called = TRUE;
     });
     $curl->error(function ($instance) use(&$success_called, &$error_called, &$complete_called, &$curl) {
         PHPUnit_Framework_Assert::assertInstanceOf('Curl', $instance);
         PHPUnit_Framework_Assert::assertFalse($success_called);
         PHPUnit_Framework_Assert::assertFalse($error_called);
         PHPUnit_Framework_Assert::assertFalse($complete_called);
         $error_called = TRUE;
     });
     $curl->complete(function ($instance) use(&$success_called, &$error_called, &$complete_called) {
         PHPUnit_Framework_Assert::assertInstanceOf('Curl', $instance);
         PHPUnit_Framework_Assert::assertFalse($success_called);
         PHPUnit_Framework_Assert::assertTrue($error_called);
         PHPUnit_Framework_Assert::assertFalse($complete_called);
         $complete_called = TRUE;
     });
     $curl->get(Test::ERROR_URL);
     $this->assertFalse($success_called);
     $this->assertTrue($error_called);
     $this->assertTrue($complete_called);
 }
开发者ID:canerdogan,项目名称:php-curl-class,代码行数:36,代码来源:run.php

示例10: die_and_log

            $content_type = trim(explode(":", $header, 2)[1]);
        }
    }
}
if (is_null($length)) {
    die_and_log($status = 400, "unknown content size:", $url);
}
if ($length > MAX_SIZE) {
    die_and_log($status = 400, "content size over: " . MAX_SIZE . "<{$length}bytes", $url);
}
if (!preg_match("/\\Aimage\\/(png|jpeg|gif)\\z/ui", $content_type)) {
    die_and_log($status = 400, "not support content type:" . $content_type, $url);
}
// get access
$c = new Curl();
$c->setHeader('X-Forwarded-For', getRemoteIP());
$c->error(function () {
    die_and_log($status = 500, "get request error");
});
$c->get($url);
// dump
header("Content-Type: {$content_type}");
echo $c->response;
//--functions--
function die_and_log($status = 400, $str = '', $extra = '')
{
    header("HTTP/1.1 {$status} Error");
    echo $str;
    error_log("{$str} :: {$extra}");
    exit;
}
开发者ID:syossan27,项目名称:JS_LGTM_Editor,代码行数:31,代码来源:proxy.php

示例11: sendRequest

 public static function sendRequest($url, $params = [], $headers = [])
 {
     $i = new Curl();
     $i->setHeader($headers);
     return $i->sendGet($url, $params);
 }
开发者ID:zivanof,项目名称:fun_project,代码行数:6,代码来源:Curl.php

示例12: setSessionCookie

 public function setSessionCookie($cookie)
 {
     $this->session_cookie = $cookie;
     $this->curl->setHeader("Cookie", $cookie);
 }
开发者ID:nilmadhab,项目名称:webtutplus,代码行数:5,代码来源:AbstractWebGsScraper2.php

示例13: loadData

 /**
  * Load data
  *
  * @param string $date
  * @param bool $reload
  * @return string
  */
 private function loadData($date, $reload = FALSE)
 {
     $this->log("load-data-start", $date);
     $parseDate = new DateTime($date);
     $myDate = new DateTime();
     $myDate->sub(new DateInterval("P2D"));
     $data = NULL;
     if ($reload || !file_exists($this->originalDataDir . "/" . $date . ".html") || $parseDate->getTimestamp() > $myDate->getTimestamp()) {
         $curl = new \Curl();
         $curl->setUserAgent("Mozilla/5.0 (compatible; NetteJabberLogParser/" . static::VERSION . "; +http://nettejabber.jdem.cz)");
         $curl->setHeader("HTTP_ACCEPT", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
         $curl->setHeader("HTTP_ACCEPT_LANGUAGE", "cs-cz,cs,en-us;q=0.7,en;q=0.3");
         $curl->setHeader("HTTP_ACCEPT_ENCODING", "gzip,deflate");
         $curl->setHeader("HTTP_ACCEPT_CHARSET", "windows-1250,utf-8;q=0.7,*;q=0.7");
         $curl->setHeader("HTTP_KEEP_ALIVE", 300);
         $curl->setHeader("HTTP_CONNECTION", "keep-alive");
         $response = $curl->get("http://nezmar.jabbim.cz/logs/nette@conf.netlab.cz/" . str_replace("-", "/", $date) . ".html");
         if ($response->getHeader("Status-Code") == 200) {
             file_put_contents($this->originalDataDir . "/" . $date . ".html", $response->getBody());
             $data = $response->getBody();
         }
     } elseif (file_exists($this->originalDataDir . "/" . $date . ".html")) {
         $data = file_get_contents($this->originalDataDir . "/" . $date . ".html");
     }
     $this->log("load-data-end", $date);
     return $data;
 }
开发者ID:Vrtak-CZ,项目名称:NJLogParser,代码行数:34,代码来源:Parser.php


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